Fix login
Browse files
app.py
CHANGED
|
@@ -8,8 +8,6 @@ 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"))
|
|
@@ -244,23 +242,12 @@ def image_to_base64(image):
|
|
| 244 |
def generate_image(edit_image_infos, did, request: gr.Request, oauth_token: gr.OAuthToken | None):
|
| 245 |
if not did:
|
| 246 |
did = str(uuid.uuid4())
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
user_name = None
|
| 252 |
-
try:
|
| 253 |
-
oauth_infos = whoami(oauth_token.token)
|
| 254 |
-
print(f"oauth_infos={oauth_infos}")
|
| 255 |
-
if oauth_infos and isinstance(oauth_infos, dict):
|
| 256 |
-
user_id = oauth_infos.get('id')
|
| 257 |
-
user_name = oauth_infos.get('name')
|
| 258 |
-
except Exception as e:
|
| 259 |
-
print(f"error: {repr(e)}")
|
| 260 |
-
m = "There was an error processing the authorization information. Please refresh the page and try again."
|
| 261 |
-
return gr.Warning(m), did
|
| 262 |
if not user_id or not user_name:
|
| 263 |
-
m = "
|
| 264 |
return gr.Warning(m), did
|
| 265 |
if edit_image_infos is None or not isinstance(edit_image_infos, dict):
|
| 266 |
m = "Please upload the main image before generating."
|
|
@@ -510,8 +497,6 @@ with gr.Blocks(css=css) as WeShop:
|
|
| 510 |
outputs=[output, current_did],
|
| 511 |
concurrency_limit=None
|
| 512 |
)
|
| 513 |
-
with gr.Row():
|
| 514 |
-
gr.LoginButton()
|
| 515 |
with gr.Column():
|
| 516 |
main_image_middleware = gr.Image(
|
| 517 |
image_mode='RGBA',
|
|
|
|
| 8 |
from PIL import Image
|
| 9 |
import uuid
|
| 10 |
import base64
|
|
|
|
|
|
|
| 11 |
|
| 12 |
example_path = os.path.join(os.path.dirname(__file__), 'assets')
|
| 13 |
clothing_list = os.listdir(os.path.join(example_path, "clothing"))
|
|
|
|
| 242 |
def generate_image(edit_image_infos, did, request: gr.Request, oauth_token: gr.OAuthToken | None):
|
| 243 |
if not did:
|
| 244 |
did = str(uuid.uuid4())
|
| 245 |
+
user_id = request.session_hash
|
| 246 |
+
if not user_id:
|
| 247 |
+
user_id = f"{login_hash_key}{user_id}"
|
| 248 |
+
user_name = request.session_hash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
if not user_id or not user_name:
|
| 250 |
+
m = "We're sorry, but there seems to be an issue with your request. Please check your network connection or refresh the page and try again."
|
| 251 |
return gr.Warning(m), did
|
| 252 |
if edit_image_infos is None or not isinstance(edit_image_infos, dict):
|
| 253 |
m = "Please upload the main image before generating."
|
|
|
|
| 497 |
outputs=[output, current_did],
|
| 498 |
concurrency_limit=None
|
| 499 |
)
|
|
|
|
|
|
|
| 500 |
with gr.Column():
|
| 501 |
main_image_middleware = gr.Image(
|
| 502 |
image_mode='RGBA',
|