Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
|
@@ -35,13 +35,16 @@ def post(
|
|
| 35 |
"Content-Type": "application/json; charset=UTF-8",
|
| 36 |
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36",
|
| 37 |
}
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
data = json.dumps({'text': text,
|
| 41 |
'translate': translate,
|
| 42 |
'seed': seed,
|
| 43 |
'only_first_stage': only_first_stage,
|
| 44 |
-
'image_prompt':
|
| 45 |
})
|
| 46 |
r = requests.post(url, data, headers=headers)
|
| 47 |
|
|
|
|
| 35 |
"Content-Type": "application/json; charset=UTF-8",
|
| 36 |
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36",
|
| 37 |
}
|
| 38 |
+
if image_prompt:
|
| 39 |
+
with open(image_prompt, "rb") as image_file:
|
| 40 |
+
encoded_img = str(base64.b64encode(image_file.read()), encoding='utf-8')
|
| 41 |
+
else:
|
| 42 |
+
encoded_img = None
|
| 43 |
data = json.dumps({'text': text,
|
| 44 |
'translate': translate,
|
| 45 |
'seed': seed,
|
| 46 |
'only_first_stage': only_first_stage,
|
| 47 |
+
'image_prompt': encoded_img
|
| 48 |
})
|
| 49 |
r = requests.post(url, data, headers=headers)
|
| 50 |
|