Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,17 +32,17 @@ transform = transforms.Compose([
|
|
32 |
# ํด๋์ค ์ด๋ฆ ๋ฆฌ์คํธ ์ ์
|
33 |
class_names = ['disposablecup', 'envmark', 'label', 'mug', 'nonlabel', 'reusablecup']
|
34 |
|
35 |
-
# ์์ธก ํจ์ ์ ์
|
36 |
def predict(image):
|
37 |
-
image = transform(image).unsqueeze(0)
|
38 |
with torch.no_grad():
|
39 |
outputs = model(image)
|
|
|
40 |
_, predicted = torch.max(outputs, 1)
|
41 |
-
# ํด๋์ค ์ธ๋ฑ์ค๋ฅผ ํด๋์ค ์ด๋ฆ์ผ๋ก ๋ณํ
|
42 |
label = class_names[predicted.item()]
|
43 |
-
print("Predicted label:", label)
|
44 |
return label
|
45 |
|
|
|
46 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|
47 |
iface = gr.Interface(fn=predict, inputs=gr.Image(type='pil'), outputs='label', live=True)
|
48 |
iface.launch()
|
|
|
32 |
# ํด๋์ค ์ด๋ฆ ๋ฆฌ์คํธ ์ ์
|
33 |
class_names = ['disposablecup', 'envmark', 'label', 'mug', 'nonlabel', 'reusablecup']
|
34 |
|
|
|
35 |
def predict(image):
|
36 |
+
image = transform(image).unsqueeze(0)
|
37 |
with torch.no_grad():
|
38 |
outputs = model(image)
|
39 |
+
print("Raw outputs:", outputs) # ์๋ณธ ์ถ๋ ฅ๊ฐ ํ์ธ
|
40 |
_, predicted = torch.max(outputs, 1)
|
|
|
41 |
label = class_names[predicted.item()]
|
42 |
+
print("Predicted label:", label)
|
43 |
return label
|
44 |
|
45 |
+
|
46 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|
47 |
iface = gr.Interface(fn=predict, inputs=gr.Image(type='pil'), outputs='label', live=True)
|
48 |
iface.launch()
|