anbarasanGT commited on
Commit
fbd0d2a
·
verified ·
1 Parent(s): e22a5a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -29,19 +29,12 @@ def query_image_generation(payload, max_retries=5):
29
  return response.content
30
  return None
31
 
 
32
  # Function for generating an image from text
33
  def generate_image(prompt):
34
  image_bytes = query_image_generation({"inputs": prompt})
35
-
36
- if image_bytes is None:
37
- return None
38
-
39
- try:
40
- image = Image.open(io.BytesIO(image_bytes)) # Opening the image from bytes
41
- return image
42
- except Exception as e:
43
- print(f"Error: {e}")
44
- return None
45
 
46
 
47
  # Updated function for text generation using the new API structure
@@ -97,11 +90,11 @@ def process_audio(audio_path, image_option, creative_text_option):
97
 
98
  # Create Gradio interface
99
  with gr.Blocks(theme=gr.themes.Base()) as iface:
100
- gr.Markdown("# Audio Transcription, Translation, Image & Creative Text Generation")
101
  with gr.Row():
102
  with gr.Column():
103
  audio_input = gr.Audio(type="filepath", label="Upload Audio File")
104
- image_option = gr.Dropdown(["Generate Image", "Skip Image"], label="Image Generation", value="Generate Image")
105
  creative_text_option = gr.Dropdown(["Generate Creative Text", "Skip Creative Text"], label="Creative Text Generation", value="Generate Creative Text")
106
  submit_button = gr.Button("Process Audio")
107
  with gr.Column():
 
29
  return response.content
30
  return None
31
 
32
+
33
  # Function for generating an image from text
34
  def generate_image(prompt):
35
  image_bytes = query_image_generation({"inputs": prompt})
36
+ image = Image.open(io.BytesIO(image_bytes)) # Opening the image from bytes
37
+ return image
 
 
 
 
 
 
 
 
38
 
39
 
40
  # Updated function for text generation using the new API structure
 
90
 
91
  # Create Gradio interface
92
  with gr.Blocks(theme=gr.themes.Base()) as iface:
93
+ gr.Markdown("# Multimodal Application for Vernacular Language Translation and Image Synthesis")
94
  with gr.Row():
95
  with gr.Column():
96
  audio_input = gr.Audio(type="filepath", label="Upload Audio File")
97
+ image_option = gr.Dropdown(["Generate Image", "Skip Image"], label="Image Generation", value="Click here to generate")
98
  creative_text_option = gr.Dropdown(["Generate Creative Text", "Skip Creative Text"], label="Creative Text Generation", value="Generate Creative Text")
99
  submit_button = gr.Button("Process Audio")
100
  with gr.Column():