Spaces:
Build error
Build error
Merge branch 'feature/divide_in_2_columns' into dev
Browse files- .gitignore +2 -0
- app.py +49 -25
- template.drawio +1 -0
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.$template.drawio.bkp
|
| 2 |
+
.$template.drawio.dtmp
|
app.py
CHANGED
|
@@ -15,9 +15,12 @@ DATASETS = [
|
|
| 15 |
MAX_N_LABELS = 5
|
| 16 |
SPLIT_TO_CLASSIFY = 'pasta'
|
| 17 |
|
| 18 |
-
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
def classify_one_image(classifier_model, dataset_to_classify):
|
| 22 |
|
| 23 |
|
|
@@ -49,58 +52,79 @@ def classify_full_dataset(shosen_dataset_name, chosen_model_name):
|
|
| 49 |
|
| 50 |
#dataset
|
| 51 |
dataset = load_dataset(shosen_dataset_name,"testedata_readme")
|
|
|
|
| 52 |
#Image teste load
|
| 53 |
image_object = dataset['pasta'][0]["image"]
|
| 54 |
-
st.image(image_object, caption="Uploaded Image", width=300)
|
| 55 |
-
st.write("### FLAG 3")
|
| 56 |
|
|
|
|
|
|
|
|
|
|
| 57 |
#modle instance
|
| 58 |
classifier_pipeline = pipeline('image-classification', model=chosen_model_name)
|
| 59 |
-
|
| 60 |
|
| 61 |
#classification
|
| 62 |
classification_result = classifier_pipeline(image_object)
|
| 63 |
-
|
| 64 |
-
|
| 65 |
#classification_array.append(classification_result)
|
| 66 |
|
| 67 |
#save classification
|
| 68 |
|
| 69 |
image_count += 1
|
| 70 |
-
|
|
|
|
| 71 |
return image_count
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
def main():
|
| 74 |
-
st.title("Bulk Image Classification DEMO")
|
| 75 |
-
st.markdown("This app uses several 🤗 models to classify images stored in 🤗 datasets.")
|
| 76 |
-
st.write("Soon we will have a dataset template")
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
#Model
|
| 84 |
-
chosen_model_name =
|
| 85 |
if chosen_model_name is not None:
|
| 86 |
-
|
|
|
|
| 87 |
|
| 88 |
#Dataset
|
| 89 |
-
shosen_dataset_name =
|
| 90 |
if shosen_dataset_name is not None:
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
#click to classify
|
| 94 |
#image_object = dataset['pasta'][0]
|
| 95 |
if chosen_model_name is not None and shosen_dataset_name is not None:
|
| 96 |
-
if
|
| 97 |
-
|
| 98 |
#classification_array =[]
|
| 99 |
classification_result = classify_full_dataset(shosen_dataset_name, chosen_model_name)
|
| 100 |
-
|
|
|
|
| 101 |
#classification_array.append(classification_result)
|
| 102 |
#st.write("# FLAG 6")
|
| 103 |
-
#st.write(classification_array)
|
| 104 |
-
|
| 105 |
if __name__ == "__main__":
|
| 106 |
main()
|
|
|
|
| 15 |
MAX_N_LABELS = 5
|
| 16 |
SPLIT_TO_CLASSIFY = 'pasta'
|
| 17 |
|
| 18 |
+
COLS = st.columns([0.75, 0.25])
|
| 19 |
+
#SCROLLABLE_TEXT = COLS[1].text_area("Conteúdo da segunda coluna", height=500)
|
| 20 |
+
SCROLLABLE_TEXT = COLS[1].container(height=500)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
def classify_one_image(classifier_model, dataset_to_classify):
|
| 25 |
|
| 26 |
|
|
|
|
| 52 |
|
| 53 |
#dataset
|
| 54 |
dataset = load_dataset(shosen_dataset_name,"testedata_readme")
|
| 55 |
+
#with SCROLLABLE_TEXT:
|
| 56 |
#Image teste load
|
| 57 |
image_object = dataset['pasta'][0]["image"]
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
SCROLLABLE_TEXT.image(image_object, caption="Uploaded Image", width=300)
|
| 60 |
+
#st.write("### FLAG 3")
|
| 61 |
+
|
| 62 |
#modle instance
|
| 63 |
classifier_pipeline = pipeline('image-classification', model=chosen_model_name)
|
| 64 |
+
#COLS[1].write("### FLAG 4")
|
| 65 |
|
| 66 |
#classification
|
| 67 |
classification_result = classifier_pipeline(image_object)
|
| 68 |
+
SCROLLABLE_TEXT.write(classification_result)
|
| 69 |
+
#COLS[1].write("### FLAG 5")
|
| 70 |
#classification_array.append(classification_result)
|
| 71 |
|
| 72 |
#save classification
|
| 73 |
|
| 74 |
image_count += 1
|
| 75 |
+
SCROLLABLE_TEXT.write("Image count")
|
| 76 |
+
SCROLLABLE_TEXT.write(image_count)
|
| 77 |
return image_count
|
| 78 |
|
| 79 |
+
|
| 80 |
+
def make_template():
|
| 81 |
+
|
| 82 |
+
tile = CONTAINER_TOP.title(":balloon:")
|
| 83 |
+
tile.title(":balloon:")
|
| 84 |
+
|
| 85 |
+
with CONTAINER_FULL:
|
| 86 |
+
CONTAINER_TOP.title("titulo de teste dentro do container CONTAINER_TOP")
|
| 87 |
+
with CONTAINER_BODY:
|
| 88 |
+
#COL1, COL2 = st.columns([3, 1])
|
| 89 |
+
with COLS[1]:
|
| 90 |
+
CONTAINER_LOOP.write("### OUTPUT")
|
| 91 |
+
|
| 92 |
+
|
| 93 |
def main():
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
+
|
| 96 |
+
COLS[0].write("# Bulk Image Classification App")
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
#with CONTAINER_BODY:
|
| 100 |
+
with COLS[0]:
|
| 101 |
+
st.markdown("This app uses several 🤗 models to classify images stored in 🤗 datasets.")
|
| 102 |
+
st.write("Soon we will have a dataset template")
|
| 103 |
|
| 104 |
#Model
|
| 105 |
+
chosen_model_name = COLS[0].selectbox("Select the model to use", MODELS, index=0)
|
| 106 |
if chosen_model_name is not None:
|
| 107 |
+
COLS[0].write("You selected")
|
| 108 |
+
COLS[0].write(chosen_model_name)
|
| 109 |
|
| 110 |
#Dataset
|
| 111 |
+
shosen_dataset_name = COLS[0].selectbox("Select the dataset to use", DATASETS, index=0)
|
| 112 |
if shosen_dataset_name is not None:
|
| 113 |
+
COLS[0].write("You selected")
|
| 114 |
+
COLS[0].write(shosen_dataset_name)
|
| 115 |
|
| 116 |
#click to classify
|
| 117 |
#image_object = dataset['pasta'][0]
|
| 118 |
if chosen_model_name is not None and shosen_dataset_name is not None:
|
| 119 |
+
if COLS[0].button("Classify images"):
|
| 120 |
+
|
| 121 |
#classification_array =[]
|
| 122 |
classification_result = classify_full_dataset(shosen_dataset_name, chosen_model_name)
|
| 123 |
+
COLS[0].write("Classification result {classification_result}")
|
| 124 |
+
COLS[0].write(classification_result)
|
| 125 |
#classification_array.append(classification_result)
|
| 126 |
#st.write("# FLAG 6")
|
| 127 |
+
#st.write(classification_array)
|
| 128 |
+
|
| 129 |
if __name__ == "__main__":
|
| 130 |
main()
|
template.drawio
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
<mxfile host="Electron" modified="2024-02-05T13:53:02.225Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/19.0.3 Chrome/102.0.5005.63 Electron/19.0.3 Safari/537.36" etag="oV2ZsfPlORpHoVp-DbXF" version="19.0.3" type="device"><diagram id="0vYW19gc_7FpzVwPDTXh" name="Página-1">3ZbPb4IwFMf/Go5LoIUC1zndDttBXbLjgvQBnYWaWof616+MIlY0mcm8eKL9vh+8ft5LwcGjcvssk1XxJihwB7l06+AnByHPxZF+NMquVYgft0IuGW0ltxfmbA9dpFE3jMLaaK2khOCKrWwxFVUFqbK0REpR226Z4NQSVkkOVhmNME8TDgO3D0ZVYVSPxL3hBVhedK8mgd9ayqTzNpnXRUJFfSThsYNHUgjVrsrtCHhDzwYzuWA9VCahUn8J2L9677Ov2WLKJstpXH3mczR7MFm+E74xJzbFql2HQIpNRaFJ4jr4sS6YgvkqSRtrrZuutUKVXO88vcwY5yPBhfyNxVmWoTTV+lpJsYQjCyULEhBtMQWAVLC9eDLvwEtPGogSlNxpFxOAQtKGmCHzItzu675lPjZpi6Nu4TA0o2LGJD/k7kHqhWF5BVd0F1xj/4RrPOTqoiFXcius+MZYoxTOY11EgR+4/4UVW1gRIQOsKIyGWFHk34irfw9cg5Nr4BxXr7uNba7oRlzDe7gGgiiwuYbBkKtLznDtGnAFV73tP4m/tqM/Czz+AQ==</diagram></mxfile>
|