Spaces:
Sleeping
Sleeping
O S I H
commited on
Commit
•
0b0076c
1
Parent(s):
b7b10e6
remove useless lines
Browse files- Dockerfile +0 -7
- api.py +1 -10
Dockerfile
CHANGED
@@ -1,6 +1,3 @@
|
|
1 |
-
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
-
# you will also find guides on how best to write your Dockerfilef
|
3 |
-
|
4 |
FROM python:3.9
|
5 |
|
6 |
WORKDIR /code
|
@@ -9,13 +6,9 @@ COPY ./requirements.txt /code/requirements.txt
|
|
9 |
|
10 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
COPY . .
|
12 |
-
# RUN git clone https://huggingface.co/MissingBreath/recycle-garbage-model
|
13 |
|
14 |
-
# RUN pip install gdown
|
15 |
RUN gdown 1-2xLqBeuq6ypWyPEVdfslKU1GLgD9a1_
|
16 |
|
17 |
-
# EXPOSE 5000
|
18 |
-
# CMD ["python", "api.py"]
|
19 |
|
20 |
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
|
21 |
|
|
|
|
|
|
|
|
|
1 |
FROM python:3.9
|
2 |
|
3 |
WORKDIR /code
|
|
|
6 |
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
COPY . .
|
|
|
9 |
|
|
|
10 |
RUN gdown 1-2xLqBeuq6ypWyPEVdfslKU1GLgD9a1_
|
11 |
|
|
|
|
|
12 |
|
13 |
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
|
14 |
|
api.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
from fastapi import FastAPI, File, UploadFile
|
2 |
-
from huggingface_hub import from_pretrained_keras
|
3 |
import numpy as np
|
4 |
from PIL import Image
|
5 |
import io
|
@@ -7,8 +6,6 @@ import tensorflow as tf
|
|
7 |
|
8 |
|
9 |
model = tf.keras.models.load_model('_9217')
|
10 |
-
# Class labels
|
11 |
-
# class_labels = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
|
12 |
|
13 |
app = FastAPI()
|
14 |
@app.post("/classify")
|
@@ -20,13 +17,7 @@ async def classify(image: UploadFile = File(...)):
|
|
20 |
img_array = np.expand_dims(img_array, axis=0)
|
21 |
predictions = model.predict(img_array)
|
22 |
predicted_class_idx = np.argmax(predictions)
|
23 |
-
predicted_class_idx = int(predicted_class_idx)
|
24 |
-
# predicted_class = class_labels[predicted_class_idx]
|
25 |
-
# return {"prediction": predicted_class}
|
26 |
return {"prediction": predicted_class_idx}
|
27 |
else:
|
28 |
return {"error": "No image provided"}
|
29 |
-
|
30 |
-
# if __name__ == "__main__":
|
31 |
-
# import uvicorn
|
32 |
-
# uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
1 |
from fastapi import FastAPI, File, UploadFile
|
|
|
2 |
import numpy as np
|
3 |
from PIL import Image
|
4 |
import io
|
|
|
6 |
|
7 |
|
8 |
model = tf.keras.models.load_model('_9217')
|
|
|
|
|
9 |
|
10 |
app = FastAPI()
|
11 |
@app.post("/classify")
|
|
|
17 |
img_array = np.expand_dims(img_array, axis=0)
|
18 |
predictions = model.predict(img_array)
|
19 |
predicted_class_idx = np.argmax(predictions)
|
20 |
+
predicted_class_idx = int(predicted_class_idx)
|
|
|
|
|
21 |
return {"prediction": predicted_class_idx}
|
22 |
else:
|
23 |
return {"error": "No image provided"}
|
|
|
|
|
|
|
|