Spaces:
Runtime error
Runtime error
Hector Lopez
commited on
Commit
·
782cec7
1
Parent(s):
4dee47a
Fixed upload file bug
Browse files
app.py
CHANGED
|
@@ -32,7 +32,8 @@ image_file = st.file_uploader("Upload Images", type=["png","jpg","jpeg"])
|
|
| 32 |
if image_file is not None:
|
| 33 |
print(image_file)
|
| 34 |
print('Getting predictions')
|
| 35 |
-
|
|
|
|
| 36 |
print('Fixing the preds')
|
| 37 |
boxes, image = prepare_prediction(pred_dict)
|
| 38 |
print('Plotting')
|
|
|
|
| 32 |
if image_file is not None:
|
| 33 |
print(image_file)
|
| 34 |
print('Getting predictions')
|
| 35 |
+
data = image_file.read()
|
| 36 |
+
pred_dict = predict(model, data)
|
| 37 |
print('Fixing the preds')
|
| 38 |
boxes, image = prepare_prediction(pred_dict)
|
| 39 |
print('Plotting')
|
model.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from icevision import *
|
| 2 |
import collections
|
| 3 |
import PIL
|
|
@@ -37,7 +38,7 @@ def get_checkpoint(checkpoint_path):
|
|
| 37 |
|
| 38 |
def predict(model, image):
|
| 39 |
#img = PIL.Image.open(image)
|
| 40 |
-
img = PIL.Image(image
|
| 41 |
print(img.shape)
|
| 42 |
class_map = ClassMap(classes=['Waste'])
|
| 43 |
transforms = tfms.A.Adapter([
|
|
|
|
| 1 |
+
from io import BytesIO
|
| 2 |
from icevision import *
|
| 3 |
import collections
|
| 4 |
import PIL
|
|
|
|
| 38 |
|
| 39 |
def predict(model, image):
|
| 40 |
#img = PIL.Image.open(image)
|
| 41 |
+
img = PIL.Image.open(BytesIO(image))
|
| 42 |
print(img.shape)
|
| 43 |
class_map = ClassMap(classes=['Waste'])
|
| 44 |
transforms = tfms.A.Adapter([
|