Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,22 +8,14 @@ os.environ['JAVAHOME'] = 'usr/bin/java'
|
|
| 8 |
|
| 9 |
Server = ServerCntrl("Start")
|
| 10 |
|
| 11 |
-
def process_input(
|
| 12 |
try:
|
| 13 |
-
|
| 14 |
-
# Convert the image to RGB format
|
| 15 |
-
img_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 16 |
-
# Perform OCR on the uploaded image
|
| 17 |
-
text_from_image = pytesseract.image_to_string(img_rgb)
|
| 18 |
-
combined_text = f"{text}\n{text_from_image}"
|
| 19 |
-
else:
|
| 20 |
-
combined_text = text
|
| 21 |
-
# Call your Generate function with the combined text
|
| 22 |
headline = Generate(combined_text,Server)
|
| 23 |
return headline
|
| 24 |
except Exception as e:
|
| 25 |
return f"Error: {e}"
|
| 26 |
|
| 27 |
|
| 28 |
-
interface = gr.Interface(fn=process_input, inputs=
|
| 29 |
interface.launch()
|
|
|
|
| 8 |
|
| 9 |
Server = ServerCntrl("Start")
|
| 10 |
|
| 11 |
+
def process_input(text):
|
| 12 |
try:
|
| 13 |
+
combined_text = text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
headline = Generate(combined_text,Server)
|
| 15 |
return headline
|
| 16 |
except Exception as e:
|
| 17 |
return f"Error: {e}"
|
| 18 |
|
| 19 |
|
| 20 |
+
interface = gr.Interface(fn=process_input, inputs="text", outputs=["text"], title="News Headline Generator with OCR")
|
| 21 |
interface.launch()
|