Spaces:
Running
Running
import gradio as gr | |
from ocr_engine import extract_text_from_image | |
from pdf_reader import extract_text_from_pdf | |
from summarizer import summarize_text | |
def process_input(pdf, image, manual_text, mode): | |
if pdf is not None: | |
text = extract_text_from_pdf(pdf) | |
elif image is not None: | |
text = extract_text_from_image(image) | |
elif manual_text.strip() != "": | |
text = manual_text | |
else: | |
return "Lütfen bir giriş türü seçin.", "" | |
summary = summarize_text(text, mode) | |
return text, summary | |
with gr.Blocks() as demo: | |
gr.Markdown("## 📚 VizSum Pro+: AI Destekli Özetleyici") | |
with gr.Row(): | |
pdf_input = gr.File(label="📄 PDF Yükle", file_types=[".pdf"]) | |
image_input = gr.Image(type="filepath", label="🖼️ Görsel Yükle") | |
manual_input = gr.Textbox(lines=5, label="✍️ Metni Manuel Gir") | |
# BURAYA AL | |
mode_selector = gr.Dropdown( | |
choices=["📘 Teknik Özet", "🧒 Sade Anlatım", "🧠 Eleştir ve Değerlendir", "📝 Başlık Çıkar", "📎 Not Formatı"], | |
label="🧩 Özetleme Modu", | |
value="📘 Teknik Özet" | |
) | |
with gr.Row(): | |
submit_btn = gr.Button("Özetle") | |
with gr.Row(): | |
text_output = gr.Textbox(label="📜 Metin") | |
summary_output = gr.Textbox(label="🧠 AI Özeti") | |
# EN SONDA KALACAK | |
submit_btn.click( | |
fn=process_input, | |
inputs=[pdf_input, image_input, manual_input, mode_selector], | |
outputs=[text_output, summary_output] | |
) | |
if __name__ == "__main__": | |
demo.launch(share=True) |