Spaces:
Paused
Paused
measmonysuon
commited on
Commit
•
d31071a
1
Parent(s):
a661009
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
|
|
2 |
from gradio_client import Client
|
3 |
import os
|
4 |
import logging
|
5 |
-
from urllib.parse import parse_qs, urlparse
|
6 |
|
7 |
# Initialize the client for image generation
|
8 |
client_image = Client("mukaist/DALLE-4K")
|
@@ -56,17 +55,8 @@ def gradio_interface(prompt, resolution_key):
|
|
56 |
else:
|
57 |
return None, "There was an error processing your photo. Please try again later."
|
58 |
|
59 |
-
def
|
60 |
-
parsed_url = urlparse(url)
|
61 |
-
params = parse_qs(parsed_url.query)
|
62 |
-
return params.get('username', ["Guest"])[0]
|
63 |
-
|
64 |
-
def create_gradio_interface(username):
|
65 |
-
description = f"Welcome, {username}! Generate images based on prompts."
|
66 |
-
|
67 |
with gr.Blocks() as interface:
|
68 |
-
gr.HTML(f"<h3>{description}</h3>")
|
69 |
-
|
70 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
71 |
resolution_dropdown = gr.Dropdown(choices=list(resolutions.keys()), label="Resolution", value="1024x1024")
|
72 |
generate_button = gr.Button("Generate")
|
@@ -89,20 +79,10 @@ def create_gradio_interface(username):
|
|
89 |
|
90 |
return interface
|
91 |
|
92 |
-
def launch_gradio(
|
93 |
-
if not username:
|
94 |
-
username = "Guest"
|
95 |
# Launch the Gradio interface
|
96 |
-
interface = create_gradio_interface(
|
97 |
interface.launch()
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
url = 'https://measmonysuon-webapp.hf.space/?username=MoMo'
|
102 |
-
username = extract_username_from_url(url)
|
103 |
-
logger.info(f"Extracted username: {username}")
|
104 |
-
return username
|
105 |
-
|
106 |
-
# Launch Gradio with the extracted or default username
|
107 |
-
username = get_username_from_url()
|
108 |
-
launch_gradio(username)
|
|
|
2 |
from gradio_client import Client
|
3 |
import os
|
4 |
import logging
|
|
|
5 |
|
6 |
# Initialize the client for image generation
|
7 |
client_image = Client("mukaist/DALLE-4K")
|
|
|
55 |
else:
|
56 |
return None, "There was an error processing your photo. Please try again later."
|
57 |
|
58 |
+
def create_gradio_interface():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
with gr.Blocks() as interface:
|
|
|
|
|
60 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
61 |
resolution_dropdown = gr.Dropdown(choices=list(resolutions.keys()), label="Resolution", value="1024x1024")
|
62 |
generate_button = gr.Button("Generate")
|
|
|
79 |
|
80 |
return interface
|
81 |
|
82 |
+
def launch_gradio():
|
|
|
|
|
83 |
# Launch the Gradio interface
|
84 |
+
interface = create_gradio_interface()
|
85 |
interface.launch()
|
86 |
|
87 |
+
if __name__ == "__main__":
|
88 |
+
launch_gradio()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|