Fix login
Browse files
app.py
CHANGED
|
@@ -7,9 +7,6 @@ import requests
|
|
| 7 |
from io import BytesIO
|
| 8 |
from PIL import Image
|
| 9 |
import uuid
|
| 10 |
-
import base64
|
| 11 |
-
import json
|
| 12 |
-
from huggingface_hub import whoami
|
| 13 |
|
| 14 |
example_path = os.path.join(os.path.dirname(__file__), 'assets')
|
| 15 |
clothing_list = os.listdir(os.path.join(example_path, "clothing"))
|
|
@@ -225,26 +222,15 @@ def load_description(file_path):
|
|
| 225 |
return content
|
| 226 |
|
| 227 |
|
| 228 |
-
def generate_image(main_image, background_image, did, request: gr.Request
|
| 229 |
if not did:
|
| 230 |
did = str(uuid.uuid4())
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
user_name = None
|
| 236 |
-
try:
|
| 237 |
-
oauth_infos = whoami(oauth_token.token)
|
| 238 |
-
print(f"oauth_infos={oauth_infos}")
|
| 239 |
-
if oauth_infos and isinstance(oauth_infos, dict):
|
| 240 |
-
user_id = oauth_infos.get('id')
|
| 241 |
-
user_name = oauth_infos.get('name')
|
| 242 |
-
except Exception as e:
|
| 243 |
-
print(f"error: {repr(e)}")
|
| 244 |
-
m = "There was an error processing the authorization information. Please refresh the page and try again."
|
| 245 |
-
return gr.Warning(m), did
|
| 246 |
if not user_id or not user_name:
|
| 247 |
-
m = "
|
| 248 |
return gr.Warning(m), did
|
| 249 |
if main_image is None or background_image is None:
|
| 250 |
m = "Please upload both the main image and the background reference image before generating."
|
|
|
|
| 7 |
from io import BytesIO
|
| 8 |
from PIL import Image
|
| 9 |
import uuid
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
example_path = os.path.join(os.path.dirname(__file__), 'assets')
|
| 12 |
clothing_list = os.listdir(os.path.join(example_path, "clothing"))
|
|
|
|
| 222 |
return content
|
| 223 |
|
| 224 |
|
| 225 |
+
def generate_image(main_image, background_image, did, request: gr.Request):
|
| 226 |
if not did:
|
| 227 |
did = str(uuid.uuid4())
|
| 228 |
+
user_id = request.session_hash
|
| 229 |
+
if not user_id:
|
| 230 |
+
user_id = f"{login_hash_key}{user_id}"
|
| 231 |
+
user_name = request.session_hash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
if not user_id or not user_name:
|
| 233 |
+
m = "There was an issue with the request. Please check your network or refresh the page and try again."
|
| 234 |
return gr.Warning(m), did
|
| 235 |
if main_image is None or background_image is None:
|
| 236 |
m = "Please upload both the main image and the background reference image before generating."
|