Pijush2023 commited on
Commit
e09a95f
·
verified ·
1 Parent(s): b04ac09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -54
app.py CHANGED
@@ -606,60 +606,6 @@ def generate_audio_meta_voice(text):
606
  logging.debug(f"Audio saved to {combined_audio_path}")
607
  return combined_audio_path
608
 
609
- pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", torch_dtype=torch.float16)
610
- pipe.to(device)
611
-
612
- def generate_image(prompt):
613
- with torch.cuda.amp.autocast():
614
- image = pipe(
615
- prompt,
616
- num_inference_steps=28,
617
- guidance_scale=3.0,
618
- ).images[0]
619
- return image
620
-
621
- hardcoded_prompt_1 = "Give a high quality photograph of a great looking red 2026 Bentley coupe against a skyline setting in the night, michael mann style in omaha enticing the consumer to buy this product"
622
- 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."
623
- 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."
624
-
625
- def update_images():
626
- image_1 = generate_image(hardcoded_prompt_1)
627
- image_2 = generate_image(hardcoded_prompt_2)
628
- image_3 = generate_image(hardcoded_prompt_3)
629
- return image_1, image_2, image_3
630
-
631
- with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
632
- with gr.Row():
633
- with gr.Column():
634
- state = gr.State()
635
-
636
- chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
637
- choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
638
-
639
- gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
640
- chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
641
- chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
642
- tts_choice = gr.Radio(label="Select TTS System", choices=["Eleven Labs", "Parler-TTS", "MARS5", "Meta Voice"], value="Eleven Labs")
643
- bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
644
- bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
645
- chatbot.like(print_like_dislike, None, None)
646
- clear_button = gr.Button("Clear")
647
- clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
648
-
649
- audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
650
- audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
651
-
652
- with gr.Column():
653
- image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
654
- image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
655
- image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
656
-
657
- refresh_button = gr.Button("Refresh Images")
658
- refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
659
-
660
- demo.queue()
661
- demo.launch(share=True)
662
-
663
  # Meta Voice setup script
664
  import subprocess
665
  import os
@@ -722,6 +668,65 @@ serving.communicate()
722
 
723
 
724
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
725
 
726
 
727
  # import gradio as gr
 
606
  logging.debug(f"Audio saved to {combined_audio_path}")
607
  return combined_audio_path
608
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
  # Meta Voice setup script
610
  import subprocess
611
  import os
 
668
 
669
 
670
 
671
+ pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", torch_dtype=torch.float16)
672
+ pipe.to(device)
673
+
674
+ def generate_image(prompt):
675
+ with torch.cuda.amp.autocast():
676
+ image = pipe(
677
+ prompt,
678
+ num_inference_steps=28,
679
+ guidance_scale=3.0,
680
+ ).images[0]
681
+ return image
682
+
683
+ hardcoded_prompt_1 = "Give a high quality photograph of a great looking red 2026 Bentley coupe against a skyline setting in the night, michael mann style in omaha enticing the consumer to buy this product"
684
+ 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."
685
+ 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."
686
+
687
+ def update_images():
688
+ image_1 = generate_image(hardcoded_prompt_1)
689
+ image_2 = generate_image(hardcoded_prompt_2)
690
+ image_3 = generate_image(hardcoded_prompt_3)
691
+ return image_1, image_2, image_3
692
+
693
+ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
694
+ with gr.Row():
695
+ with gr.Column():
696
+ state = gr.State()
697
+
698
+ chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
699
+ choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
700
+
701
+ gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
702
+ chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
703
+ chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
704
+ tts_choice = gr.Radio(label="Select TTS System", choices=["Eleven Labs", "Parler-TTS", "MARS5", "Meta Voice"], value="Eleven Labs")
705
+ bot_msg = chat_msg.then(bot, [chatbot, choice, tts_choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
706
+ bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
707
+ chatbot.like(print_like_dislike, None, None)
708
+ clear_button = gr.Button("Clear")
709
+ clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
710
+
711
+ audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
712
+ audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
713
+
714
+ with gr.Column():
715
+ image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
716
+ image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
717
+ image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
718
+
719
+ refresh_button = gr.Button("Refresh Images")
720
+ refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
721
+
722
+ demo.queue()
723
+ demo.launch(share=True)
724
+
725
+
726
+
727
+
728
+
729
+
730
 
731
 
732
  # import gradio as gr