tommy24 commited on
Commit
4a9aada
·
1 Parent(s): 81dc57e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
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
- byt_headers = {
761
- "Authorization": f"Bearer {g_auth}"
762
- }
763
- upload_response = requests.post("https://api.bytescale.com/v2/accounts/12a1yeH/uploads/form_data", data=image_data, headers=byt_headers)
764
- if upload_response.status_code == 200:
765
- response_json = upload_response.json()
766
- image_url = response_json.get('url')
767
- if image_url:
768
- print(f"Image uploaded successfully. URL: {image_url}")
769
- else:
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)