Pijush2023 commited on
Commit
28c5ccf
·
verified ·
1 Parent(s): b8472b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -689,6 +689,29 @@ def generate_map(location_names):
689
  return map_html
690
 
691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
  def fetch_local_news():
693
  api_key = os.environ['SERP_API']
694
  url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
@@ -1425,6 +1448,14 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1425
  news_output = gr.HTML(value=fetch_local_news())
1426
  events_output = gr.HTML(value=fetch_local_events())
1427
 
 
 
 
 
 
 
 
 
1428
  demo.queue()
1429
  demo.launch(show_error=True)
1430
 
 
689
  return map_html
690
 
691
 
692
+ pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", torch_dtype=torch.float16)
693
+ pipe.to(device)
694
+
695
+ def generate_image(prompt):
696
+ with torch.cuda.amp.autocast():
697
+ image = pipe(
698
+ prompt,
699
+ num_inference_steps=28,
700
+ guidance_scale=3.0,
701
+ ).images[0]
702
+ return image
703
+
704
+ hardcoded_prompt_1 = "Give a high quality photograph of a great looking red 2026 Toyota coupe against a skyline setting in the night, michael mann style in omaha enticing the consumer to buy this product"
705
+ hardcoded_prompt_2 = "A vibrant and dynamic football game scene in the style of Peter Paul Rubens, showcasing the intense match between Alabama and Nebraska. The players are depicted with the dramatic, muscular physiques and expressive faces typical of Rubens' style. The Alabama team is wearing their iconic crimson and white uniforms, while the Nebraska team is in their classic red and white attire. The scene is filled with action, with players in mid-motion, tackling, running, and catching the ball. The background features a grand stadium filled with cheering fans, banners, and the natural landscape in the distance. The colors are rich and vibrant, with a strong use of light and shadow to create depth and drama. The overall atmosphere captures the intensity and excitement of the game, infused with the grandeur and dynamism characteristic of Rubens' work."
706
+ hardcoded_prompt_3 = "Create a high-energy scene of a DJ performing on a large stage with vibrant lights, colorful lasers, a lively dancing crowd, and various electronic equipment in the background."
707
+
708
+ def update_images():
709
+ image_1 = generate_image(hardcoded_prompt_1)
710
+ image_2 = generate_image(hardcoded_prompt_2)
711
+ image_3 = generate_image(hardcoded_prompt_3)
712
+ return image_1, image_2, image_3
713
+
714
+
715
  def fetch_local_news():
716
  api_key = os.environ['SERP_API']
717
  url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
 
1448
  news_output = gr.HTML(value=fetch_local_news())
1449
  events_output = gr.HTML(value=fetch_local_events())
1450
 
1451
+ with gr.Column():
1452
+ image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
1453
+ image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
1454
+ image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
1455
+
1456
+ refresh_button = gr.Button("Refresh Images")
1457
+ refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3], api_name="update_image")
1458
+
1459
  demo.queue()
1460
  demo.launch(show_error=True)
1461