Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import io
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
reader = PyPDF2.PdfReader(io.BytesIO(pdf_file))
|
8 |
-
text = ""
|
9 |
-
for page in range(len(reader.pages)):
|
10 |
-
text += reader.pages[page].extract_text()
|
11 |
-
return text
|
12 |
|
13 |
-
#
|
14 |
-
def
|
15 |
-
|
16 |
-
if question in extracted_text:
|
17 |
-
start = extracted_text.find(question)
|
18 |
-
end = extracted_text.find('.', start) + 1
|
19 |
-
return extracted_text[start:end]
|
20 |
-
else:
|
21 |
-
return "์ง๋ฌธ์ ๋ํ ๋ต๋ณ์ ์ฐพ์ ์ ์์ต๋๋ค."
|
22 |
|
23 |
-
# Gradio
|
24 |
iface = gr.Interface(
|
25 |
-
fn=
|
26 |
-
inputs=
|
27 |
-
outputs=gr.
|
28 |
)
|
29 |
|
30 |
-
#
|
31 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
|
|
3 |
|
4 |
+
# Hugging Face์ ํธ๋์คํฌ๋จธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด ๋ชจ๋ธ์ ๋ก๋ํฉ๋๋ค.
|
5 |
+
model = pipeline("text-classification", model="InstantX/InstantID")
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
# ๋ชจ๋ธ์ ํธ์ถํ๋ ํจ์๋ฅผ ์ ์ํฉ๋๋ค.
|
8 |
+
def predict(text):
|
9 |
+
return model(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
# Gradio ์ธํฐํ์ด์ค๋ฅผ ๋ง๋ญ๋๋ค.
|
12 |
iface = gr.Interface(
|
13 |
+
fn=predict,
|
14 |
+
inputs=gr.Textbox(lines=2, placeholder="Type something here..."),
|
15 |
+
outputs=[gr.Label(num_top_classes=3), gr.Dataframe()],
|
16 |
)
|
17 |
|
18 |
+
# ์ธํฐํ์ด์ค๋ฅผ ์คํํ์ฌ ํ
์คํธํฉ๋๋ค.
|
19 |
iface.launch()
|