tommy24 commited on
Commit
445fcd6
·
1 Parent(s): b9dc973

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -359,26 +359,19 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
359
  if platform == "wh":
360
  get_image = requests.get(Images, headers=headers)
361
  if get_image.status_code == 200:
362
- print(get_image.content)
363
- random_id = random.randint(1000, 9999)
364
- file_extension = ".png"
365
- filename = f"image_{random_id}{file_extension}"
366
- with open(filename, "wb") as file:
367
- file.write(get_image.content)
368
- print(f"Saved image as: {filename}")
369
  elif platform == "web":
370
  print("WEB")
371
  # Handle web case if needed
372
  else:
373
  pass
374
 
375
- image = cv.imread(filename)
376
  image = cv.resize(image, (224, 224))
377
  image_array = np.asarray(image)
378
- image_data = cv.resize(imageData, (224, 224))
379
  normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1
380
  data[0] = normalized_image_array
381
-
382
  prediction = model.predict(data)
383
 
384
  max_label_index = None
 
359
  if platform == "wh":
360
  get_image = requests.get(Images, headers=headers)
361
  if get_image.status_code == 200:
362
+ image_data = get_image.content
 
 
 
 
 
 
363
  elif platform == "web":
364
  print("WEB")
365
  # Handle web case if needed
366
  else:
367
  pass
368
 
369
+ image = cv.imdecode(np.frombuffer(image_data, np.uint8), cv.IMREAD_COLOR)
370
  image = cv.resize(image, (224, 224))
371
  image_array = np.asarray(image)
 
372
  normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1
373
  data[0] = normalized_image_array
374
+
375
  prediction = model.predict(data)
376
 
377
  max_label_index = None