Nuno-Tome commited on
Commit
22b8a05
1 Parent(s): fa64131

no message

Browse files
Files changed (1) hide show
  1. app.py +25 -23
app.py CHANGED
@@ -14,8 +14,9 @@ DATASETS = [
14
  ]
15
  MAX_N_LABELS = 5
16
 
17
-
18
- def old_classify_images(classifier_model, dataset_to_classify):
 
19
 
20
  for image in dataset:
21
  st("Image classification: ", image['file'])
@@ -32,28 +33,31 @@ def old_classify_images(classifier_model, dataset_to_classify):
32
 
33
 
34
  def classify_full_dataset(shosen_dataset_name, chosen_model_name):
35
-
 
36
  #dataset
37
  dataset = load_dataset(shosen_dataset_name,"testedata_readme")
38
- st.write("# FLAG 2")
39
-
40
  #Image teste load
41
  image_object = dataset['pasta'][0]["image"]
42
- st.image(image_object, caption="Uploaded Image", use_column_width=True)
43
- st.write("# FLAG 3")
44
 
45
  #modle instance
46
  classifier_pipeline = pipeline('image-classification', model=chosen_model_name)
47
- #classifier_pipeline = pipeline('image-classification', model="nateraw/vit-age-classifier", device=0)
48
- st.write("# FLAG 4")
49
  #classification
50
- classification_result = classify(image_object, classifier_pipeline)
51
  st.write(classification_result)
52
- st.write("# FLAG 5")
53
-
54
-
55
 
56
- return "done"
 
 
 
 
 
57
 
58
 
59
 
@@ -77,15 +81,13 @@ def main():
77
  #image_object = dataset['pasta'][0]
78
  if chosen_model_name is not None and shosen_dataset_name is not None:
79
  if st.button("Classify images"):
80
-
81
- classification_array =[]
82
-
83
- st.write("# FLAG 1")
84
- classification_result = classify(shosen_dataset_name, chosen_model_name)
85
-
86
- classification_array.append(classification_result)
87
- st.write("# FLAG 6")
88
- st.write(classification_array)
89
 
90
  if __name__ == "__main__":
91
  main()
 
14
  ]
15
  MAX_N_LABELS = 5
16
 
17
+ #(image_object, classifier_pipeline)
18
+ #def classify_one_image(classifier_model, dataset_to_classify):
19
+ def classify_one_image(classifier_model, dataset_to_classify):
20
 
21
  for image in dataset:
22
  st("Image classification: ", image['file'])
 
33
 
34
 
35
  def classify_full_dataset(shosen_dataset_name, chosen_model_name):
36
+ image_count = 0
37
+
38
  #dataset
39
  dataset = load_dataset(shosen_dataset_name,"testedata_readme")
 
 
40
  #Image teste load
41
  image_object = dataset['pasta'][0]["image"]
42
+ st.image(image_object, caption="Uploaded Image", height=300)
43
+ st.write("### FLAG 3")
44
 
45
  #modle instance
46
  classifier_pipeline = pipeline('image-classification', model=chosen_model_name)
47
+ st.write("### FLAG 4")
48
+
49
  #classification
50
+ classification_result = classify_one_image(image_object, classifier_pipeline)
51
  st.write(classification_result)
52
+ st.write("### FLAG 5")
53
+ #classification_array.append(classification_result)
 
54
 
55
+ #save classification
56
+
57
+
58
+ image_count += 1
59
+
60
+ return image_count
61
 
62
 
63
 
 
81
  #image_object = dataset['pasta'][0]
82
  if chosen_model_name is not None and shosen_dataset_name is not None:
83
  if st.button("Classify images"):
84
+
85
+ #classification_array =[]
86
+ classification_result = classify_full_dataset(shosen_dataset_name, chosen_model_name)
87
+ st.write(f"Classification result: {classification_result}")
88
+ #classification_array.append(classification_result)
89
+ #st.write("# FLAG 6")
90
+ #st.write(classification_array)
 
 
91
 
92
  if __name__ == "__main__":
93
  main()