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 |
human_list = os.listdir(os.path.join(example_path, "human"))
|
|
@@ -224,23 +221,12 @@ def load_description(file_path):
|
|
| 224 |
def generate_image(main_image, text_description, did, request: gr.Request, oauth_token: gr.OAuthToken | None):
|
| 225 |
if not did:
|
| 226 |
did = str(uuid.uuid4())
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
user_name = None
|
| 232 |
-
try:
|
| 233 |
-
oauth_infos = whoami(oauth_token.token)
|
| 234 |
-
print(f"oauth_infos={oauth_infos}, {int(time.time())}")
|
| 235 |
-
if oauth_infos and isinstance(oauth_infos, dict):
|
| 236 |
-
user_id = oauth_infos.get('id')
|
| 237 |
-
user_name = oauth_infos.get('name')
|
| 238 |
-
except Exception as e:
|
| 239 |
-
print(f"error: {repr(e)}")
|
| 240 |
-
m = "There was an error processing the authorization information. Please refresh the page and try again."
|
| 241 |
-
return gr.Warning(m), did
|
| 242 |
if not user_id or not user_name:
|
| 243 |
-
m = "
|
| 244 |
return gr.Warning(m), did
|
| 245 |
if main_image is None:
|
| 246 |
m = "Please upload both the main image and the background reference image before generating."
|
|
@@ -445,8 +431,6 @@ with gr.Blocks(css=css) as WeShop:
|
|
| 445 |
outputs=[output, current_did],
|
| 446 |
concurrency_limit=None
|
| 447 |
)
|
| 448 |
-
with gr.Row():
|
| 449 |
-
gr.LoginButton()
|
| 450 |
with gr.Column():
|
| 451 |
show_case = gr.Examples(
|
| 452 |
examples=[
|
|
|
|
| 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 |
human_list = os.listdir(os.path.join(example_path, "human"))
|
|
|
|
| 221 |
def generate_image(main_image, text_description, did, request: gr.Request, oauth_token: gr.OAuthToken | None):
|
| 222 |
if not did:
|
| 223 |
did = str(uuid.uuid4())
|
| 224 |
+
user_id = request.session_hash
|
| 225 |
+
if not user_id:
|
| 226 |
+
user_id = f"{login_hash_key}{user_id}"
|
| 227 |
+
user_name = request.session_hash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
if not user_id or not user_name:
|
| 229 |
+
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."
|
| 230 |
return gr.Warning(m), did
|
| 231 |
if main_image is None:
|
| 232 |
m = "Please upload both the main image and the background reference image before generating."
|
|
|
|
| 431 |
outputs=[output, current_did],
|
| 432 |
concurrency_limit=None
|
| 433 |
)
|
|
|
|
|
|
|
| 434 |
with gr.Column():
|
| 435 |
show_case = gr.Examples(
|
| 436 |
examples=[
|