patrickerichsen commited on
Commit
ab30774
1 Parent(s): f0c0a77
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ flagged
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: ScubaSpotter
3
- emoji: 📚
4
  colorFrom: blue
5
  colorTo: gray
6
  sdk: gradio
@@ -10,4 +10,6 @@ pinned: false
10
  license: apache-2.0
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
  title: ScubaSpotter
3
+ emoji: 🤿
4
  colorFrom: blue
5
  colorTo: gray
6
  sdk: gradio
 
10
  license: apache-2.0
11
  ---
12
 
13
+ ```python
14
+ python app.py
15
+ ```
app.py CHANGED
@@ -1,7 +1,24 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
 
4
+ title = "ScubaSpotter 🤿"
5
+ description = "An image classifier for underwater marine life, including scuba divers themselves. Trained on the [Sea Animals Image Dataset](https://www.kaggle.com/datasets/vencerlanz09/sea-animals-image-dataste)."
6
+ examples = ['./examples/clam.jpg', './examples/scuba_diver.jpg', './examples/turtle.jpg']
7
 
8
+ learn = load_learner('export.pkl')
9
+
10
+ labels = learn.dls.vocab
11
+
12
+ def predict(img):
13
+ img = PILImage.create(img)
14
+ pred,pred_idx,probs = learn.predict(img)
15
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
16
+
17
+ def most_confident_prediction(img):
18
+ img = PILImage.create(img)
19
+ pred, pred_idx, probs = learn.predict(img)
20
+ predictions = {labels[i]: float(probs[i]) for i in range(len(labels))}
21
+ most_confident_prediction = max(predictions.items(), key=lambda x: x[1])
22
+ return {most_confident_prediction[0]: float(most_confident_prediction[1])}
23
+
24
+ gr.Interface(fn=most_confident_prediction, inputs="image", outputs="label", title=title,description=description,examples=examples).launch(share=True)
examples/clam.jpg ADDED
examples/scuba_diver.jpg ADDED
examples/turtle.jpg ADDED
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:486828594daf8863628b22c5e80517b3a0bf6c3856aff3578482dd7d644ad28c
3
+ size 47160653
requirements.txt ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.2.0
3
+ annotated-types==0.6.0
4
+ anyio==4.3.0
5
+ attrs==23.2.0
6
+ blis==0.7.11
7
+ catalogue==2.0.10
8
+ certifi==2024.2.2
9
+ charset-normalizer==3.3.2
10
+ click==8.1.7
11
+ cloudpathlib==0.16.0
12
+ colorama==0.4.6
13
+ confection==0.1.4
14
+ contourpy==1.2.0
15
+ cycler==0.12.1
16
+ cymem==2.0.8
17
+ exceptiongroup==1.2.0
18
+ fastai==2.7.14
19
+ fastapi==0.110.0
20
+ fastcore==1.5.29
21
+ fastdownload==0.0.7
22
+ fastprogress==1.0.3
23
+ ffmpy==0.3.2
24
+ filelock==3.13.1
25
+ fonttools==4.49.0
26
+ fsspec==2024.2.0
27
+ gradio==4.21.0
28
+ gradio_client==0.12.0
29
+ h11==0.14.0
30
+ httpcore==1.0.4
31
+ httpx==0.27.0
32
+ huggingface-hub==0.21.4
33
+ idna==3.6
34
+ importlib_resources==6.3.0
35
+ Jinja2==3.1.3
36
+ joblib==1.3.2
37
+ jsonschema==4.21.1
38
+ jsonschema-specifications==2023.12.1
39
+ kiwisolver==1.4.5
40
+ langcodes==3.3.0
41
+ markdown-it-py==3.0.0
42
+ MarkupSafe==2.1.5
43
+ matplotlib==3.8.3
44
+ mdurl==0.1.2
45
+ mpmath==1.3.0
46
+ murmurhash==1.0.10
47
+ networkx==3.2.1
48
+ numpy==1.26.4
49
+ orjson==3.9.15
50
+ packaging==24.0
51
+ pandas==2.2.1
52
+ pillow==10.2.0
53
+ preshed==3.0.9
54
+ pydantic==2.6.4
55
+ pydantic_core==2.16.3
56
+ pydub==0.25.1
57
+ Pygments==2.17.2
58
+ pyparsing==3.1.2
59
+ python-dateutil==2.9.0.post0
60
+ python-multipart==0.0.9
61
+ pytz==2024.1
62
+ PyYAML==6.0.1
63
+ referencing==0.33.0
64
+ requests==2.31.0
65
+ rich==13.7.1
66
+ rpds-py==0.18.0
67
+ ruff==0.3.2
68
+ scikit-learn==1.4.1.post1
69
+ scipy==1.12.0
70
+ semantic-version==2.10.0
71
+ shellingham==1.5.4
72
+ six==1.16.0
73
+ smart-open==6.4.0
74
+ sniffio==1.3.1
75
+ spacy==3.7.4
76
+ spacy-legacy==3.0.12
77
+ spacy-loggers==1.0.5
78
+ srsly==2.4.8
79
+ starlette==0.36.3
80
+ sympy==1.12
81
+ thinc==8.2.3
82
+ threadpoolctl==3.3.0
83
+ tomlkit==0.12.0
84
+ toolz==0.12.1
85
+ torch==2.2.1
86
+ torchvision==0.17.1
87
+ tqdm==4.66.2
88
+ typer==0.9.0
89
+ typing_extensions==4.10.0
90
+ tzdata==2024.1
91
+ urllib3==1.26.6
92
+ uvicorn==0.28.0
93
+ wasabi==1.1.2
94
+ weasel==0.3.4
95
+ websockets==11.0.3
96
+ zipp==3.18.0