yutaogawa commited on
Commit
d209cfd
1 Parent(s): b7d6a9e

Change app.py to use a HuggingFace sample model.

Browse files
Files changed (3) hide show
  1. .vscode/settings.json +3 -0
  2. app.py +18 -4
  3. requirements.txt +73 -0
.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "python.pythonPath": "env\\Scripts\\python.exe"
3
+ }
app.py CHANGED
@@ -1,7 +1,21 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return f"Hello {name}!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
 
5
 
6
+ # def greet(name):
7
+ # return f"Hello {name}!"
8
+
9
+ # demo = gr.Interface(fn=greet, inputs="text", outputs="text")
10
+
11
+ def predict(image):
12
+ predictions = pipeline(image)
13
+ return {p["label"]: p["score"] for p in predictions}
14
+
15
+ demo = gr.Interface(
16
+ predict,
17
+ inputs=gr.inputs.Image(label="Upload hot dog candidate", type="filepath"),
18
+ outputs=gr.outputs.Label(num_top_classes=2),
19
+ title="Hot Dog? Or Not?"
20
+ )
21
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.1.0
2
+ aiohttp==3.8.4
3
+ aiosignal==1.3.1
4
+ altair==4.2.2
5
+ anyio==3.6.2
6
+ async-timeout==4.0.2
7
+ attrs==22.2.0
8
+ certifi==2022.12.7
9
+ charset-normalizer==3.1.0
10
+ click==8.1.3
11
+ colorama==0.4.6
12
+ contourpy==1.0.7
13
+ cycler==0.11.0
14
+ entrypoints==0.4
15
+ fastapi==0.95.0
16
+ ffmpy==0.3.0
17
+ filelock==3.10.7
18
+ fonttools==4.39.3
19
+ frozenlist==1.3.3
20
+ fsspec==2023.3.0
21
+ gradio==3.24.0
22
+ gradio_client==0.0.5
23
+ h11==0.14.0
24
+ httpcore==0.16.3
25
+ httpx==0.23.3
26
+ huggingface-hub==0.13.3
27
+ idna==3.4
28
+ importlib-resources==5.12.0
29
+ Jinja2==3.1.2
30
+ jsonschema==4.17.3
31
+ kiwisolver==1.4.4
32
+ linkify-it-py==2.0.0
33
+ markdown-it-py==2.2.0
34
+ MarkupSafe==2.1.2
35
+ matplotlib==3.7.1
36
+ mdit-py-plugins==0.3.3
37
+ mdurl==0.1.2
38
+ mpmath==1.3.0
39
+ multidict==6.0.4
40
+ networkx==3.0
41
+ numpy==1.24.2
42
+ orjson==3.8.9
43
+ packaging==23.0
44
+ pandas==1.5.3
45
+ Pillow==9.4.0
46
+ pydantic==1.10.7
47
+ pydub==0.25.1
48
+ pyparsing==3.0.9
49
+ pyrsistent==0.19.3
50
+ python-dateutil==2.8.2
51
+ python-multipart==0.0.6
52
+ pytz==2023.3
53
+ PyYAML==6.0
54
+ regex==2023.3.23
55
+ requests==2.28.2
56
+ rfc3986==1.5.0
57
+ semantic-version==2.10.0
58
+ six==1.16.0
59
+ sniffio==1.3.0
60
+ starlette==0.26.1
61
+ sympy==1.11.1
62
+ tokenizers==0.13.2
63
+ toolz==0.12.0
64
+ torch==2.0.0
65
+ tqdm==4.65.0
66
+ transformers==4.27.4
67
+ typing_extensions==4.5.0
68
+ uc-micro-py==1.0.1
69
+ urllib3==1.26.15
70
+ uvicorn==0.21.1
71
+ websockets==10.4
72
+ yarl==1.8.2
73
+ zipp==3.15.0