Spaces:
Sleeping
Sleeping
dhanesh123in
commited on
Commit
•
02a29e3
1
Parent(s):
c940a92
initial commit
Browse files- app.py +46 -0
- requirements.txt +34 -0
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from io import BytesIO
|
4 |
+
from PIL import Image
|
5 |
+
import time
|
6 |
+
|
7 |
+
from transformers import AutoImageProcessor, ViTForImageClassification
|
8 |
+
import torch
|
9 |
+
|
10 |
+
image_processor = AutoImageProcessor.from_pretrained("dhanesh123in/image_classification_obipix_birdID")
|
11 |
+
model_s = ViTForImageClassification.from_pretrained("dhanesh123in/image_classification_obipix_birdID")
|
12 |
+
|
13 |
+
st.title("Welcome to Bird Species Identification App!")
|
14 |
+
|
15 |
+
uploaded_file = st.file_uploader("Upload Image")
|
16 |
+
if uploaded_file is not None:
|
17 |
+
# To read file as bytes:
|
18 |
+
bytes_data = uploaded_file.getvalue()
|
19 |
+
|
20 |
+
image = Image.open(BytesIO(bytes_data))
|
21 |
+
inputs = image_processor(image, return_tensors="pt")
|
22 |
+
|
23 |
+
with torch.no_grad():
|
24 |
+
logits = model_s(**inputs).logits
|
25 |
+
|
26 |
+
# model predicts one of the 1000 ImageNet classes
|
27 |
+
predicted_label = logits.argmax(-1).item()
|
28 |
+
prediction=model_s.config.id2label[predicted_label]
|
29 |
+
|
30 |
+
|
31 |
+
with st.spinner('Our well trained AI assistant is looking at your image...'):
|
32 |
+
time.sleep(5)
|
33 |
+
st.success("Prediction is "+prediction)
|
34 |
+
|
35 |
+
st.image(bytes_data)
|
36 |
+
|
37 |
+
x=st.radio("Was this correct?",["Yes","No"],horizontal=True)
|
38 |
+
|
39 |
+
if (x=="No"):
|
40 |
+
st.write("Oops.. more to learn I guess")
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
accelerate==0.28.0
|
2 |
+
conllu==4.5.3
|
3 |
+
elasticsearch==8.11.1
|
4 |
+
evaluate==0.4.1
|
5 |
+
faiss-cpu==1.7.4
|
6 |
+
fire==0.5.0
|
7 |
+
fqdn==1.5.1
|
8 |
+
git-python==1.0.3
|
9 |
+
importlib-resources==6.1.1
|
10 |
+
isoduration==20.11.0
|
11 |
+
jiwer==3.0.3
|
12 |
+
jsonpointer==2.4
|
13 |
+
librosa==0.10.1
|
14 |
+
matplotlib==3.8.2
|
15 |
+
notebook==7.0.6
|
16 |
+
nvidia-cuda-nvcc-cu12==12.2.140
|
17 |
+
opencv-python==4.8.1.78
|
18 |
+
patchify==0.2.3
|
19 |
+
pip-chill==1.0.3
|
20 |
+
pipfreeze==2.0.3
|
21 |
+
py7zr==0.21.0
|
22 |
+
pytest==7.4.3
|
23 |
+
rouge-score==0.1.2
|
24 |
+
sacrebleu==2.3.3
|
25 |
+
sentencepiece==0.2.0
|
26 |
+
seqeval==1.2.2
|
27 |
+
streamlit==1.29.0
|
28 |
+
tensorflow==2.15.0.post1
|
29 |
+
tensorflow-datasets==4.9.3
|
30 |
+
torchaudio==0.12.1+cu113
|
31 |
+
torchvision==0.13.1+cu113
|
32 |
+
transformers==4.38.2
|
33 |
+
uri-template==1.3.0
|
34 |
+
webcolors==1.13
|