0-ma commited on
Commit
079d565
·
verified ·
1 Parent(s): 4addd34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -10
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import numpy as np
3
  from PIL import Image
4
  from transformers import AutoImageProcessor, AutoModelForImageClassification
5
-
6
  model_names = [
7
  "0-ma/swin-geometric-shapes-tiny",
8
  "0-ma/mobilenet-v2-geometric-shapes",
@@ -15,16 +15,29 @@ model_names = [
15
  "0-ma/vit-geometric-shapes-tiny",
16
  ]
17
 
18
- example_images = [
19
- 'example/1_None.jpg',
20
- 'example/2_Circle.jpg',
21
- 'example/3_Triangle.jpg',
22
- 'example/4_Square.jpg',
23
- 'example/5_Pentagone.jpg',
24
- 'example/6_Hexagone.jpg'
25
- ]
26
 
27
- labels = [example.split("_")[1].split(".")[0] for example in example_images]
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  feature_extractors = {model_name: AutoImageProcessor.from_pretrained(model_name) for model_name in model_names}
30
  classification_models = {model_name: AutoModelForImageClassification.from_pretrained(model_name) for model_name in model_names}
 
2
  import numpy as np
3
  from PIL import Image
4
  from transformers import AutoImageProcessor, AutoModelForImageClassification
5
+ import os
6
  model_names = [
7
  "0-ma/swin-geometric-shapes-tiny",
8
  "0-ma/mobilenet-v2-geometric-shapes",
 
15
  "0-ma/vit-geometric-shapes-tiny",
16
  ]
17
 
18
+ # example_images = [
19
+ # 'example/1_None.jpg',
20
+ # 'example/2_Circle.jpg',
21
+ # 'example/3_Triangle.jpg',
22
+ # 'example/4_Square.jpg',
23
+ # 'example/5_Pentagone.jpg',
24
+ # 'example/6_Hexagone.jpg'
25
+ # ]
26
 
27
+ example_dir = "./example"
28
+ example_images = []
29
+ for example_image in os.list_dir(example_dir):
30
+ example_images+= [os.path.join(example_dir,example_image)]
31
+
32
+ #labels = [example.split("_")[1].split(".")[0] for example in example_images]
33
+ labels = [
34
+ 'None',
35
+ 'Circle',
36
+ 'Triangle',
37
+ 'Square',
38
+ 'Pentagone',
39
+ 'Hexagone'
40
+ ]
41
 
42
  feature_extractors = {model_name: AutoImageProcessor.from_pretrained(model_name) for model_name in model_names}
43
  classification_models = {model_name: AutoModelForImageClassification.from_pretrained(model_name) for model_name in model_names}