Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,11 +5,6 @@ import gradio as gr
|
|
| 5 |
from booknlp.booknlp import BookNLP
|
| 6 |
from spacy.cli import download
|
| 7 |
|
| 8 |
-
|
| 9 |
-
#This will download the booknlp files using my huggingface backup
|
| 10 |
-
import download_missing_booknlp_models
|
| 11 |
-
|
| 12 |
-
|
| 13 |
# Ensure Spacy model is downloaded
|
| 14 |
def ensure_spacy_model():
|
| 15 |
try:
|
|
@@ -44,13 +39,14 @@ def process_book(file):
|
|
| 44 |
booknlp.process(input_file, output_dir, book_id)
|
| 45 |
|
| 46 |
# Zip the output folder
|
|
|
|
| 47 |
shutil.make_archive(f"{output_dir}/{book_id}_output", 'zip', output_dir)
|
| 48 |
-
return
|
| 49 |
|
| 50 |
# Gradio Interface
|
| 51 |
def gradio_interface():
|
| 52 |
-
file_input = gr.
|
| 53 |
-
file_output = gr.
|
| 54 |
|
| 55 |
gr.Interface(
|
| 56 |
fn=process_book,
|
|
|
|
| 5 |
from booknlp.booknlp import BookNLP
|
| 6 |
from spacy.cli import download
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Ensure Spacy model is downloaded
|
| 9 |
def ensure_spacy_model():
|
| 10 |
try:
|
|
|
|
| 39 |
booknlp.process(input_file, output_dir, book_id)
|
| 40 |
|
| 41 |
# Zip the output folder
|
| 42 |
+
zip_file = f"{output_dir}/{book_id}_output.zip"
|
| 43 |
shutil.make_archive(f"{output_dir}/{book_id}_output", 'zip', output_dir)
|
| 44 |
+
return zip_file
|
| 45 |
|
| 46 |
# Gradio Interface
|
| 47 |
def gradio_interface():
|
| 48 |
+
file_input = gr.File(file_types=['.txt'], label="Upload a .txt file")
|
| 49 |
+
file_output = gr.File(label="Download the output files")
|
| 50 |
|
| 51 |
gr.Interface(
|
| 52 |
fn=process_book,
|