Nuno-Tome commited on
Commit
cc65489
1 Parent(s): 5523bc2

1st version is ready to teste

Browse files
Files changed (1) hide show
  1. app.py +47 -9
app.py CHANGED
@@ -5,28 +5,66 @@ from datasets import load_dataset, Image, list_datasets
5
  from PIL import Image
6
 
7
  MODELS = [
 
8
  "google/vit-base-patch16-224", #Classifição geral
9
  "nateraw/vit-age-classifier" #Classifição de idade
10
  ]
 
 
 
 
 
11
  MAX_N_LABELS = 5
12
 
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  def main():
16
  st.title("Bulk Image Classification")
17
  st.markdown("This app uses several 🤗 models to classify images stored in 🤗 datasets.")
18
  st.write("Soon we will have a dataset template")
19
  st.write("**Soon we will have dataset selector**")
20
- st.text("Select a model to use:")
21
- st.get_option("model", MODELS)
22
- dataset = load_dataset("Nunt/testedata","testedata_readme")
23
- st.markdown("The models available are:")
24
- st.markdown("**PUT IT HERE**")
25
-
26
-
27
- dataset = load_dataset("Nunt/testedata","testedata_readme")
28
-
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
 
32
  if __name__ == "__main__":
 
5
  from PIL import Image
6
 
7
  MODELS = [
8
+ "",
9
  "google/vit-base-patch16-224", #Classifição geral
10
  "nateraw/vit-age-classifier" #Classifição de idade
11
  ]
12
+ DATASETS = [
13
+ "",
14
+ "NunT/vit-base-patch16-224", #Classifição geral
15
+ "NunT/vit-age-classifier" #Classifição de idade
16
+ ]
17
  MAX_N_LABELS = 5
18
 
19
 
20
+ def classify_images(classifier_model, dataset_to_classify):
21
+
22
+ for image in dataset:
23
+ st("Image classification: ", image['file'])
24
+ '''
25
+ image_path = image['file']
26
+ img = Image.open(image_path)
27
+ st.image(img, caption="Original image", use_column_width=True)
28
+ results = classifier(image_path, top_k=MAX_N_LABELS)
29
+ st.write(results)
30
+ st.write("----")
31
+ '''
32
+
33
+
34
 
35
  def main():
36
  st.title("Bulk Image Classification")
37
  st.markdown("This app uses several 🤗 models to classify images stored in 🤗 datasets.")
38
  st.write("Soon we will have a dataset template")
39
  st.write("**Soon we will have dataset selector**")
 
 
 
 
 
 
 
 
 
40
 
41
+
42
+ '''
43
+ Model
44
+ '''
45
+ shosen_model_name = st.selectbox("Select the model to use", MODELS)
46
+ if shosen_model is not None:
47
+ st.write("You selected", shosen_model_name)
48
+
49
+ '''
50
+ Dataset
51
+ '''
52
+ shosen_dataset_name =st.radio("Select the model to use", MODELS)
53
+ if shosen_dataset is not None:
54
+ st.write("You selected", shosen_dataset_name)
55
+ image_object = dataset['pasta'][0]["image"]
56
+
57
+
58
+
59
+
60
+ if shosen_model is not None and shosen_dataset is not None:
61
+ st.image(shosen_dataset[0], caption="Uploaded Image", use_column_width=True)
62
+ if st.button("Classify images"):
63
+ dataset = load_dataset("Nunt/testedata","testedata_readme")
64
+ classifier = pipeline('image-classification', model=model_name, device=0)
65
+ classify_images(classifier, dataset)
66
+
67
+
68
 
69
 
70
  if __name__ == "__main__":