WoodLB commited on
Commit
005ffc6
·
1 Parent(s): 1e6e6f3

finished app no frills

Browse files
Files changed (1) hide show
  1. app.py +25 -27
app.py CHANGED
@@ -95,33 +95,31 @@ def train_and_inference(api_key, ontology_id, model_run_id):
95
  import requests
96
  import os
97
 
98
- import os
99
- import requests
100
- from urllib.parse import unquote
101
-
102
- def download_and_save_image(url, destination_folder, filename):
103
- try:
104
- # Decode the URL
105
- url = unquote(url)
106
-
107
- # Ensure destination directory exists
108
- if not os.path.exists(destination_folder):
109
- os.makedirs(destination_folder)
110
-
111
- # Start the download process
112
- response = requests.get(url, stream=True)
113
-
114
- # Check if the request was successful
115
- if response.status_code == 200:
116
- file_path = os.path.join(destination_folder, filename)
117
- with open(file_path, 'wb') as file:
118
- for chunk in response.iter_content(8192):
119
- file.write(chunk)
120
- st.write(f"Image downloaded and saved: {file_path}")
121
- else:
122
- st.write(f"Failed to download the image. Status code: {response.status_code}")
123
- except Exception as e:
124
- st.write(f"An error occurred: {e}")
125
 
126
 
127
 
 
95
  import requests
96
  import os
97
 
98
+ from urllib.parse import unquote
99
+
100
+ def download_and_save_image(url, destination_folder, filename):
101
+ try:
102
+ # Decode the URL
103
+ url = unquote(url)
104
+
105
+ # Ensure destination directory exists
106
+ if not os.path.exists(destination_folder):
107
+ os.makedirs(destination_folder)
108
+
109
+ # Start the download process
110
+ response = requests.get(url, stream=True)
111
+
112
+ # Check if the request was successful
113
+ if response.status_code == 200:
114
+ file_path = os.path.join(destination_folder, filename)
115
+ with open(file_path, 'wb') as file:
116
+ for chunk in response.iter_content(8192):
117
+ file.write(chunk)
118
+ st.write(f"Image downloaded and saved: {file_path}")
119
+ else:
120
+ st.write(f"Failed to download the image. Status code: {response.status_code}")
121
+ except Exception as e:
122
+ st.write(f"An error occurred: {e}")
 
 
123
 
124
 
125