Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -757,20 +757,16 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
| 757 |
get_image = requests.get(Images, headers=headers)
|
| 758 |
if get_image.status_code == 200:
|
| 759 |
image_data = get_image.content
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
|
| 770 |
-
print("Failed to get image URL from Byteslash response.")
|
| 771 |
-
else:
|
| 772 |
-
print(f"Failed to upload image to Byteslash. Status Code: {upload_response.status_code}")
|
| 773 |
-
|
| 774 |
elif platform == "web":
|
| 775 |
# print("WEB")
|
| 776 |
url = requests.get(Images)
|
|
|
|
| 757 |
get_image = requests.get(Images, headers=headers)
|
| 758 |
if get_image.status_code == 200:
|
| 759 |
image_data = get_image.content
|
| 760 |
+
folder_name = "upload"
|
| 761 |
+
file_name = "saved_image.jpg"
|
| 762 |
+
|
| 763 |
+
os.makedirs(folder_name, exist_ok=True)
|
| 764 |
+
|
| 765 |
+
file_path = os.path.join(folder_name, file_name)
|
| 766 |
+
with open(file_path, 'wb') as file:
|
| 767 |
+
file.write(image_data)
|
| 768 |
+
|
| 769 |
+
print(f"Image saved successfully to {file_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 770 |
elif platform == "web":
|
| 771 |
# print("WEB")
|
| 772 |
url = requests.get(Images)
|