Spaces:
Runtime error
Runtime error
Michael Stivala
commited on
Commit
•
95c7232
1
Parent(s):
2b0a350
WIP
Browse files- app.py +20 -4
- jazzmaster.jpeg +0 -0
- model.pkl +3 -0
- requirements.txt +62 -0
- serve.py +24 -0
- stratocaster.jpeg +0 -0
- telecaster.jpeg +0 -0
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import pickle
|
3 |
|
4 |
+
categories = ['Telecaster', 'Stratocaster', 'Jazzmaster']
|
5 |
+
examples = ['stratocaster.jpt', 'telecaster.jpg', 'jazzmaster.jpg']
|
6 |
+
image = gr.inputs.Image(shape=(192, 192))
|
7 |
+
label = gr.outputs.Label()
|
8 |
|
9 |
+
# Load the trained model from the model.pkl file
|
10 |
+
with open("model.pkl", "rb") as f:
|
11 |
+
model = pickle.load(f)
|
12 |
+
|
13 |
+
|
14 |
+
def predict(image):
|
15 |
+
# image = cv2.resize(image, (224, 224))
|
16 |
+
# image = np.expand_dims(image, axis=0)
|
17 |
+
prediction, idx, probabilities = model.predict(image)
|
18 |
+
return dict(zip(categories, map(float, probabilities)))
|
19 |
+
|
20 |
+
|
21 |
+
iface = gr.Interface(fn=predict, inputs=image, outputs=label,
|
22 |
+
examples=examples, capture_session=True)
|
23 |
+
iface.launch()
|
jazzmaster.jpeg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f516a4010723ec3b58a91e97fa317ddb97dd81a8b34becce9956714efa219199
|
3 |
+
size 102886051
|
requirements.txt
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohttp==3.8.3
|
2 |
+
aiosignal==1.3.1
|
3 |
+
altair==4.2.0
|
4 |
+
anyio==3.6.2
|
5 |
+
async-timeout==4.0.2
|
6 |
+
attrs==22.2.0
|
7 |
+
certifi==2022.12.7
|
8 |
+
charset-normalizer==2.1.1
|
9 |
+
click==8.1.3
|
10 |
+
contourpy==1.0.6
|
11 |
+
cycler==0.11.0
|
12 |
+
distlib==0.3.6
|
13 |
+
entrypoints==0.4
|
14 |
+
fastapi==0.88.0
|
15 |
+
ffmpy==0.3.0
|
16 |
+
filelock==3.8.2
|
17 |
+
fonttools==4.38.0
|
18 |
+
frozenlist==1.3.3
|
19 |
+
fsspec==2022.11.0
|
20 |
+
gradio==3.15.0
|
21 |
+
h11==0.14.0
|
22 |
+
httpcore==0.16.3
|
23 |
+
httpx==0.23.1
|
24 |
+
idna==3.4
|
25 |
+
Jinja2==3.1.2
|
26 |
+
jsonschema==4.17.3
|
27 |
+
kiwisolver==1.4.4
|
28 |
+
linkify-it-py==1.0.3
|
29 |
+
markdown-it-py==2.1.0
|
30 |
+
MarkupSafe==2.1.1
|
31 |
+
matplotlib==3.6.2
|
32 |
+
mdit-py-plugins==0.3.3
|
33 |
+
mdurl==0.1.2
|
34 |
+
multidict==6.0.3
|
35 |
+
numpy==1.24.0
|
36 |
+
orjson==3.8.3
|
37 |
+
packaging==22.0
|
38 |
+
pandas==1.5.2
|
39 |
+
Pillow==9.3.0
|
40 |
+
platformdirs==2.6.0
|
41 |
+
pycryptodome==3.16.0
|
42 |
+
pydantic==1.10.2
|
43 |
+
pydub==0.25.1
|
44 |
+
pyparsing==3.0.9
|
45 |
+
pyrsistent==0.19.2
|
46 |
+
python-dateutil==2.8.2
|
47 |
+
python-multipart==0.0.5
|
48 |
+
pytz==2022.7
|
49 |
+
PyYAML==6.0
|
50 |
+
requests==2.28.1
|
51 |
+
rfc3986==1.5.0
|
52 |
+
six==1.16.0
|
53 |
+
sniffio==1.3.0
|
54 |
+
starlette==0.22.0
|
55 |
+
toolz==0.12.0
|
56 |
+
typing_extensions==4.4.0
|
57 |
+
uc-micro-py==1.0.1
|
58 |
+
urllib3==1.26.13
|
59 |
+
uvicorn==0.20.0
|
60 |
+
virtualenv==20.17.1
|
61 |
+
websockets==10.4
|
62 |
+
yarl==1.8.2
|
serve.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
import subprocess
|
3 |
+
import sys
|
4 |
+
|
5 |
+
from watchdog.observers import Observer
|
6 |
+
from watchdog.events import FileSystemEventHandler
|
7 |
+
|
8 |
+
|
9 |
+
class ScriptReloader(FileSystemEventHandler):
|
10 |
+
def on_modified(self, event):
|
11 |
+
subprocess.run([sys.executable, "app.py"])
|
12 |
+
|
13 |
+
|
14 |
+
observer = Observer()
|
15 |
+
event_handler = ScriptReloader()
|
16 |
+
observer.schedule(event_handler, "app.py", recursive=True)
|
17 |
+
observer.start()
|
18 |
+
|
19 |
+
try:
|
20 |
+
while True:
|
21 |
+
time.sleep(1)
|
22 |
+
except KeyboardInterrupt:
|
23 |
+
observer.stop()
|
24 |
+
observer.join()
|
stratocaster.jpeg
ADDED
telecaster.jpeg
ADDED