Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -359,10 +359,17 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
359 |
get_image = requests.get(Images, headers=headers)
|
360 |
if get_image.status_code == 200:
|
361 |
# print(get_image.content)
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
elif platform == "web":
|
367 |
print("WEB")
|
368 |
# Handle web case if needed
|
@@ -370,15 +377,10 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
370 |
pass
|
371 |
|
372 |
image_data = cv.resize(imageData, (224, 224))
|
373 |
-
normalized_image_array = (
|
374 |
-
data = np.zeros((1, 224, 224, 3))
|
375 |
data[0] = normalized_image_array
|
376 |
-
prediction = model.predict(data)
|
377 |
-
# image_data = cv.resize(imageData, (224, 224))
|
378 |
-
# normalized_image_array = (image_data.astype(np.float32) / 127.0) - 1
|
379 |
-
# data[0] = normalized_image_array
|
380 |
|
381 |
-
|
382 |
|
383 |
max_label_index = None
|
384 |
max_prediction_value = -1
|
|
|
359 |
get_image = requests.get(Images, headers=headers)
|
360 |
if get_image.status_code == 200:
|
361 |
# print(get_image.content)
|
362 |
+
random_id = random.randint(1000, 9999)
|
363 |
+
|
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 |
+
|
369 |
+
print(f"Saved image as: {filename}")
|
370 |
+
|
371 |
+
full_path = os.path.join(os.getcwd(), filename)
|
372 |
+
print(f"Saved image as: {full_path}")
|
373 |
elif platform == "web":
|
374 |
print("WEB")
|
375 |
# Handle web case if needed
|
|
|
377 |
pass
|
378 |
|
379 |
image_data = cv.resize(imageData, (224, 224))
|
380 |
+
normalized_image_array = (image_data.astype(np.float32) / 127.0) - 1
|
|
|
381 |
data[0] = normalized_image_array
|
|
|
|
|
|
|
|
|
382 |
|
383 |
+
prediction = model.predict(data)
|
384 |
|
385 |
max_label_index = None
|
386 |
max_prediction_value = -1
|