Nausad commited on
Commit
e14fed6
·
verified ·
1 Parent(s): 79204eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -110,17 +110,25 @@ def predict():
110
  print("Bytes length:", len(image_bytes))
111
  print("First 50 bytes:", image_bytes[:50])
112
 
113
- try:
114
- img = Image.open(io.BytesIO(image_bytes))
115
- img = img.convert("RGB")
116
 
117
- tensor = transform(img).unsqueeze(0).to(device)
 
 
 
 
 
 
 
 
118
 
119
- with torch.no_grad():
120
- logits = model(tensor)
121
- probs = F.softmax(logits, dim=1).squeeze(0)
122
 
123
- return jsonify({"success": True})
 
 
 
124
 
125
  except Exception as e:
126
  print("ERROR:", e)
 
110
  print("Bytes length:", len(image_bytes))
111
  print("First 50 bytes:", image_bytes[:50])
112
 
113
+ try:
114
+ data = file.read()
 
115
 
116
+ print("Filename:", file.filename)
117
+ print("Content-Type:", file.content_type)
118
+ print("Bytes length:", len(data))
119
+
120
+ img = Image.open(io.BytesIO(data))
121
+ print("Format:", img.format)
122
+ print("Size:", img.size)
123
+
124
+ img = img.convert("RGB")
125
 
126
+ tensor = transform(img).unsqueeze(0).to(device)
 
 
127
 
128
+ t0 = time.time()
129
+ with torch.no_grad():
130
+ logits = model(tensor)
131
+ probs = F.softmax(logits, dim=1).squeeze(0)
132
 
133
  except Exception as e:
134
  print("ERROR:", e)