Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -28,6 +28,20 @@ def image_to_base64(image_path):
|
|
28 |
encoded_string = base64.b64encode(img.read()).decode('utf-8')
|
29 |
return f"data:image/jpeg;base64,{encoded_string}"
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
@spaces.GPU(duration=90)
|
32 |
def run_inference(message, history):
|
33 |
## may work
|
|
|
28 |
encoded_string = base64.b64encode(img.read()).decode('utf-8')
|
29 |
return f"data:image/jpeg;base64,{encoded_string}"
|
30 |
|
31 |
+
import requests
|
32 |
+
import base64
|
33 |
+
|
34 |
+
def url_to_base64(image_url):
|
35 |
+
# Fetch the image from the URL
|
36 |
+
response = requests.get(image_url)
|
37 |
+
if response.status_code == 200:
|
38 |
+
# Encode image content to Base64
|
39 |
+
base64_image = base64.b64encode(response.content).decode('utf-8')
|
40 |
+
return base64_image
|
41 |
+
else:
|
42 |
+
return ''
|
43 |
+
|
44 |
+
|
45 |
@spaces.GPU(duration=90)
|
46 |
def run_inference(message, history):
|
47 |
## may work
|