hellodav commited on
Commit
a7a1018
·
verified ·
1 Parent(s): 50764c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,10 +1,13 @@
1
-
2
  import gradio as gr
3
  from transformers import AutoModelForCausalLM, pipeline
4
  from PIL import Image
5
  import pandas as pd
6
  import pytesseract
7
 
 
 
 
8
  # Load models
9
  text_model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)
10
  tts_pipeline = pipeline("text-to-speech", model="parler-tts/parler-tts-large-v1")
@@ -35,10 +38,10 @@ def handle_files(file):
35
  else:
36
  image = Image.open(file)
37
  text = process_image(image)
38
-
39
  # Generate audio from the text
40
  audio = tts_pipeline(text)
41
-
42
  return text, audio["audio"]
43
 
44
  # Gradio interface
 
1
+ import os
2
  import gradio as gr
3
  from transformers import AutoModelForCausalLM, pipeline
4
  from PIL import Image
5
  import pandas as pd
6
  import pytesseract
7
 
8
+ # Install missing dependencies
9
+ os.system("pip install transformers pandas pillow pytesseract")
10
+
11
  # Load models
12
  text_model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)
13
  tts_pipeline = pipeline("text-to-speech", model="parler-tts/parler-tts-large-v1")
 
38
  else:
39
  image = Image.open(file)
40
  text = process_image(image)
41
+
42
  # Generate audio from the text
43
  audio = tts_pipeline(text)
44
+
45
  return text, audio["audio"]
46
 
47
  # Gradio interface