Matej commited on
Commit
369faf1
1 Parent(s): 87508dc
Files changed (6) hide show
  1. .gitignore +4 -0
  2. app.py +46 -0
  3. examples/molly.jpg +0 -0
  4. examples/nala.jpg +0 -0
  5. readme.txt +0 -0
  6. requirements.txt +97 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .ipynb_checkpoints
2
+ flagged
3
+ model_checkpoints
4
+ saved_model
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ from huggingface_hub import from_pretrained_keras
4
+ from tensorflow.keras import mixed_precision
5
+
6
+ # Load your trained models
7
+ model = from_pretrained_keras("ml-debi/EfficientNetV2S-StanfordDogsA")
8
+
9
+ # Add information about the models
10
+ model_info = """
11
+ ### Model Information
12
+
13
+ """
14
+
15
+ examples = [["./examples/nala.jpg"], ["./examples/molly.jpg"]]
16
+
17
+ def preprocess(image):
18
+ print("before resize", image.shape)
19
+ image = tf.image.resize(image, [224, 224])
20
+
21
+ image = tf.expand_dims(image, axis=0)
22
+ print("After expanddims", image.shape)
23
+ return image
24
+
25
+ def predict(image):
26
+
27
+ if mixed_precision.global_policy() == "mixed_float16":
28
+ mixed_precision.set_global_policy(policy="float32")
29
+
30
+ image = preprocess(image)
31
+ print(mixed_precision.global_policy())
32
+ prediction = model.predict(image)[0]
33
+ print("model prediction", prediction)
34
+ confidences = {model.config['id2label'][str(i)]: float(prediction[i]) for i in range(101)}
35
+ return confidences
36
+
37
+ iface = gr.Interface(
38
+ fn=predict,
39
+ inputs=[gr.Image()],
40
+ outputs=[gr.Label(num_top_classes=5)],
41
+ title="Dog Vision Mini Project",
42
+ description=f"{model_info}\n",
43
+ examples=examples
44
+ )
45
+
46
+ iface.launch()
examples/molly.jpg ADDED
examples/nala.jpg ADDED
readme.txt ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==2.0.0
2
+ aiofiles==23.2.1
3
+ altair==5.1.2
4
+ annotated-types==0.6.0
5
+ anyio==3.7.1
6
+ astunparse==1.6.3
7
+ attrs==23.1.0
8
+ cachetools==5.3.2
9
+ certifi==2023.7.22
10
+ charset-normalizer==3.3.2
11
+ click==8.1.7
12
+ colorama==0.4.6
13
+ contourpy==1.2.0
14
+ cycler==0.12.1
15
+ exceptiongroup==1.1.3
16
+ fastapi==0.104.1
17
+ ffmpy==0.3.1
18
+ filelock==3.13.1
19
+ flatbuffers==23.5.26
20
+ fonttools==4.44.0
21
+ fsspec==2023.10.0
22
+ gast==0.5.4
23
+ google-auth==2.23.4
24
+ google-auth-oauthlib==1.0.0
25
+ google-pasta==0.2.0
26
+ gradio==4.1.2
27
+ gradio_client==0.7.0
28
+ grpcio==1.59.2
29
+ h11==0.14.0
30
+ h5py==3.10.0
31
+ httpcore==1.0.1
32
+ httpx==0.25.1
33
+ huggingface-hub==0.19.0
34
+ idna==3.4
35
+ importlib-metadata==6.8.0
36
+ importlib-resources==6.1.1
37
+ Jinja2==3.1.2
38
+ jsonschema==4.19.2
39
+ jsonschema-specifications==2023.7.1
40
+ keras==2.14.0
41
+ kiwisolver==1.4.5
42
+ libclang==16.0.6
43
+ Markdown==3.5.1
44
+ markdown-it-py==3.0.0
45
+ MarkupSafe==2.1.3
46
+ matplotlib==3.8.1
47
+ mdurl==0.1.2
48
+ ml-dtypes==0.2.0
49
+ numpy==1.26.1
50
+ oauthlib==3.2.2
51
+ opt-einsum==3.3.0
52
+ orjson==3.9.10
53
+ packaging==23.2
54
+ pandas==2.1.2
55
+ Pillow==10.1.0
56
+ protobuf==4.25.0
57
+ pyasn1==0.5.0
58
+ pyasn1-modules==0.3.0
59
+ pydantic==2.4.2
60
+ pydantic_core==2.10.1
61
+ pydub==0.25.1
62
+ Pygments==2.16.1
63
+ pyparsing==3.1.1
64
+ python-dateutil==2.8.2
65
+ python-multipart==0.0.6
66
+ pytz==2023.3.post1
67
+ PyYAML==6.0.1
68
+ referencing==0.30.2
69
+ requests==2.31.0
70
+ requests-oauthlib==1.3.1
71
+ rich==13.6.0
72
+ rpds-py==0.12.0
73
+ rsa==4.9
74
+ semantic-version==2.10.0
75
+ shellingham==1.5.4
76
+ six==1.16.0
77
+ sniffio==1.3.0
78
+ starlette==0.27.0
79
+ tensorboard==2.14.1
80
+ tensorboard-data-server==0.7.2
81
+ tensorflow==2.14.0
82
+ tensorflow-estimator==2.14.0
83
+ tensorflow-intel==2.14.0
84
+ tensorflow-io-gcs-filesystem==0.31.0
85
+ termcolor==2.3.0
86
+ tomlkit==0.12.0
87
+ toolz==0.12.0
88
+ tqdm==4.66.1
89
+ typer==0.9.0
90
+ typing_extensions==4.8.0
91
+ tzdata==2023.3
92
+ urllib3==2.0.7
93
+ uvicorn==0.24.0.post1
94
+ websockets==11.0.3
95
+ Werkzeug==3.0.1
96
+ wrapt==1.14.1
97
+ zipp==3.17.0