quazar002 commited on
Commit
cc2a7fc
·
verified ·
1 Parent(s): 277afd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -33,14 +33,24 @@ transform = transforms.Compose([
33
  transforms.Normalize(mean=[0.5]*3, std=[0.5]*3)
34
  ])
35
 
 
 
 
 
 
 
 
 
 
 
36
  def predict(img: Image.Image):
37
  return classify_image(img)
38
 
 
39
  gr.Interface(
40
- fn=predict, # ✅ this matches the /run/predict endpoint your app calls
41
  inputs=gr.Image(type="pil"),
42
  outputs="label",
43
  title="Luxury Item Authenticity Detector",
44
  description="Upload an image to check if it's a real or fake item."
45
  ).launch()
46
-
 
33
  transforms.Normalize(mean=[0.5]*3, std=[0.5]*3)
34
  ])
35
 
36
+ # ✅ Define classify_image first
37
+ def classify_image(img: Image.Image):
38
+ img_tensor = transform(img).unsqueeze(0)
39
+ with torch.no_grad():
40
+ outputs = model(img_tensor)
41
+ _, predicted = torch.max(outputs, 1)
42
+ label = 'Fake' if predicted.item() == 0 else 'Real'
43
+ return label
44
+
45
+ # ✅ Then wrap it in predict()
46
  def predict(img: Image.Image):
47
  return classify_image(img)
48
 
49
+ # ✅ All set to go
50
  gr.Interface(
51
+ fn=predict,
52
  inputs=gr.Image(type="pil"),
53
  outputs="label",
54
  title="Luxury Item Authenticity Detector",
55
  description="Upload an image to check if it's a real or fake item."
56
  ).launch()