File size: 1,560 Bytes
cc21f11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0303b9b
 
cc21f11
 
 
 
 
0303b9b
cc21f11
 
0303b9b
 
cc21f11
0303b9b
cc21f11
 
0303b9b
 
 
cc21f11
 
 
 
 
 
0303b9b
 
cc21f11
 
 
 
 
 
 
 
0303b9b
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
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.", ""

    if "[ERROR]" in text or "[INFO]" in text:
        return text, ""

    summary = summarize_text(text, mode)
    return text, summary

with gr.Blocks() as demo:
    gr.Markdown("## VizSum Pro+: AI Destekli Özetleme Aracı")

    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")

    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="Giriş Metni")
        summary_output = gr.Textbox(label="AI Özeti")

    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)