kjn1009 commited on
Commit
ac1d126
ยท
verified ยท
1 Parent(s): f94173d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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()