SpyC0der77 commited on
Commit
43c1fd4
·
verified ·
1 Parent(s): f5b81b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -18,7 +18,7 @@ def infer(
18
  num_inference_steps,
19
  user_info,
20
  ):
21
- if user_info is None:
22
  return "Please log in to generate images.", None
23
 
24
  # Load the pipeline only when this function is called
@@ -62,20 +62,18 @@ with gr.Blocks(css=css) as demo:
62
  with gr.Column(elem_id="col-container"):
63
  gr.Markdown(" # Text-to-Image Gradio Template")
64
 
65
- # Add the LoginButton
66
  login_button = gr.LoginButton()
 
67
  user_info = gr.State()
68
 
69
- # Function to update user_info upon login
70
  def update_user_info(profile):
71
- if profile is None:
72
- return gr.Error("Please log in to access the application.")
73
  return profile
74
 
75
- # Update user_info when login_button is clicked
76
- login_button.click(update_user_info, inputs=None, outputs=user_info)
 
77
 
78
- # Main interface
79
  with gr.Row():
80
  prompt = gr.Text(
81
  label="Prompt",
 
18
  num_inference_steps,
19
  user_info,
20
  ):
21
+ if not user_info or not user_info.get("username"):
22
  return "Please log in to generate images.", None
23
 
24
  # Load the pipeline only when this function is called
 
62
  with gr.Column(elem_id="col-container"):
63
  gr.Markdown(" # Text-to-Image Gradio Template")
64
 
65
+ # Login Button inside the Blocks context
66
  login_button = gr.LoginButton()
67
+ login_button.activate()
68
  user_info = gr.State()
69
 
 
70
  def update_user_info(profile):
 
 
71
  return profile
72
 
73
+ login_button.click(
74
+ update_user_info, inputs=None, outputs=user_info
75
+ )
76
 
 
77
  with gr.Row():
78
  prompt = gr.Text(
79
  label="Prompt",