Spaces:
Sleeping
Sleeping
Commit
·
14b32f8
1
Parent(s):
5660235
minor fixes
Browse files
README.md
CHANGED
|
@@ -36,6 +36,6 @@ The following files are present in this repository:
|
|
| 36 |
|
| 37 |
- `app.py`: The main Streamlit app file to run directly.
|
| 38 |
- `requirements.txt`: The list of Python dependencies required by the app.
|
| 39 |
-
- `model.py`: Contains the code for loading and using the
|
| 40 |
-
- `app_endpoint.py`: Contains
|
| 41 |
- `app_with_fastapi.py`: Contains the code for the Streamlit app with FastAPI endpoint.
|
|
|
|
| 36 |
|
| 37 |
- `app.py`: The main Streamlit app file to run directly.
|
| 38 |
- `requirements.txt`: The list of Python dependencies required by the app.
|
| 39 |
+
- `model.py`: Contains the code for loading and using the model.
|
| 40 |
+
- `app_endpoint.py`: Contains FASTAPI endpoint for the prediction.
|
| 41 |
- `app_with_fastapi.py`: Contains the code for the Streamlit app with FastAPI endpoint.
|
app.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
from PIL import Image
|
| 2 |
import streamlit as st
|
| 3 |
-
import requests
|
| 4 |
import model
|
| 5 |
|
| 6 |
-
|
| 7 |
st.title("CIFAR10 Prediction")
|
| 8 |
|
| 9 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
|
|
|
| 1 |
from PIL import Image
|
| 2 |
import streamlit as st
|
|
|
|
| 3 |
import model
|
| 4 |
|
| 5 |
+
|
| 6 |
st.title("CIFAR10 Prediction")
|
| 7 |
|
| 8 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
app_with_fastapi.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import requests
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
-
# Streamlit layout
|
| 5 |
st.title("CIFAR10 Prediction")
|
| 6 |
|
| 7 |
HOST = "http://localhost:8000"
|
|
|
|
| 1 |
import requests
|
| 2 |
import streamlit as st
|
| 3 |
|
|
|
|
| 4 |
st.title("CIFAR10 Prediction")
|
| 5 |
|
| 6 |
HOST = "http://localhost:8000"
|
model.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
| 1 |
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 2 |
import torch
|
| 3 |
|
|
|
|
| 4 |
processor = AutoImageProcessor.from_pretrained("heyitskim1912/AML_A2_Q4")
|
| 5 |
model = AutoModelForImageClassification.from_pretrained("heyitskim1912/AML_A2_Q4")
|
| 6 |
|
| 7 |
def predict(image_pil):
|
| 8 |
inputs = processor(image_pil, return_tensors="pt")
|
| 9 |
|
|
|
|
| 10 |
with torch.no_grad():
|
| 11 |
logits = model(**inputs).logits
|
| 12 |
|
|
|
|
| 1 |
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 2 |
import torch
|
| 3 |
|
| 4 |
+
# Loading processor and model
|
| 5 |
processor = AutoImageProcessor.from_pretrained("heyitskim1912/AML_A2_Q4")
|
| 6 |
model = AutoModelForImageClassification.from_pretrained("heyitskim1912/AML_A2_Q4")
|
| 7 |
|
| 8 |
def predict(image_pil):
|
| 9 |
inputs = processor(image_pil, return_tensors="pt")
|
| 10 |
|
| 11 |
+
#Inference
|
| 12 |
with torch.no_grad():
|
| 13 |
logits = model(**inputs).logits
|
| 14 |
|