Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
from PyPDF2 import PdfReader
|
|
|
3 |
from PIL import Image
|
4 |
|
5 |
def process_file(file, file_type):
|
6 |
if file_type == "PDF":
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
return None, f"File PDF berisi:\n{text}"
|
13 |
elif file_type == "Image":
|
14 |
# Menampilkan gambar
|
15 |
image = Image.open(file.name)
|
@@ -27,5 +27,5 @@ interface = gr.Interface(
|
|
27 |
description="Pilih tipe file dan unggah file gambar atau PDF untuk diproses."
|
28 |
)
|
29 |
|
30 |
-
# Jalankan antarmuka
|
31 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from PyPDF2 import PdfReader
|
3 |
+
from pdf2image import convert_from_path
|
4 |
from PIL import Image
|
5 |
|
6 |
def process_file(file, file_type):
|
7 |
if file_type == "PDF":
|
8 |
+
# Mengonversi PDF ke gambar
|
9 |
+
images = convert_from_path(file.name)
|
10 |
+
# Menyimpan gambar pertama sebagai output
|
11 |
+
image = images[0] # Mengambil halaman pertama
|
12 |
+
return image, None
|
|
|
13 |
elif file_type == "Image":
|
14 |
# Menampilkan gambar
|
15 |
image = Image.open(file.name)
|
|
|
27 |
description="Pilih tipe file dan unggah file gambar atau PDF untuk diproses."
|
28 |
)
|
29 |
|
30 |
+
# Jalankan antarmuka dengan opsi share=True
|
31 |
interface.launch()
|