File size: 1,589 Bytes
cc21f11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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)