heaversm commited on
Commit
dc1d5f9
·
1 Parent(s): 448c83b
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -29,7 +29,11 @@ credentials = service_account.Credentials.from_service_account_info(service_acco
29
  project="pdr-imagen"
30
  aiplatform.init(project=project, credentials=credentials)
31
 
32
- def generate_image(prompt,model_name):
 
 
 
 
33
  try:
34
  model = ImageGenerationModel.from_pretrained(model_name)
35
  response = model.generate_images(
@@ -49,6 +53,10 @@ with gr.Blocks() as demo:
49
 
50
  gr.Markdown("# <center>Google Vertex Imagen Generator</center>")
51
 
 
 
 
 
52
  #instructions
53
  with gr.Accordion("Instructions & Tips",label="instructions",open=False):
54
  with gr.Row():
@@ -67,7 +75,7 @@ with gr.Blocks() as demo:
67
  with gr.Accordion("Image Output",label="Image Output",open=True):
68
  output_image = gr.Image(label="Image")
69
 
70
- btn.click(fn=generate_image, inputs=[text, model ], outputs=output_image, api_name=False)
71
- text.submit(fn=generate_image, inputs=[text, model ], outputs=output_image, api_name="generate_image") # Generate an api endpoint in Gradio / HF
72
 
73
  demo.launch(share=False)
 
29
  project="pdr-imagen"
30
  aiplatform.init(project=project, credentials=credentials)
31
 
32
+ def generate_image(pw,prompt,model_name):
33
+
34
+ if pw != os.getenv("PW"):
35
+ raise gr.Error("Invalid password. Please try again.")
36
+
37
  try:
38
  model = ImageGenerationModel.from_pretrained(model_name)
39
  response = model.generate_images(
 
53
 
54
  gr.Markdown("# <center>Google Vertex Imagen Generator</center>")
55
 
56
+ #password
57
+ pw = gr.Textbox(label="Password", type="password", placeholder="Enter the password to unlock the service")
58
+ gr.Markdown("Need access? Send a DM to @HeaversMike on Twitter or send me an email / Slack msg.")
59
+
60
  #instructions
61
  with gr.Accordion("Instructions & Tips",label="instructions",open=False):
62
  with gr.Row():
 
75
  with gr.Accordion("Image Output",label="Image Output",open=True):
76
  output_image = gr.Image(label="Image")
77
 
78
+ btn.click(fn=generate_image, inputs=[pw,text, model ], outputs=output_image, api_name=False)
79
+ text.submit(fn=generate_image, inputs=[pw,text, model ], outputs=output_image, api_name="generate_image") # Generate an api endpoint in Gradio / HF
80
 
81
  demo.launch(share=False)