Spaces:
Sleeping
Sleeping
Update app.py
Browse filesHmmm... Almost done😫
app.py
CHANGED
|
@@ -31,12 +31,12 @@ if pdf_file is not None:
|
|
| 31 |
st.write("Processing the PDF...")
|
| 32 |
text = extract_text_from_pdf(pdf_file)
|
| 33 |
if text.strip():
|
| 34 |
-
st.write("PDF Text Extracted.
|
| 35 |
classifier = pipeline("zero-shot-classification", model = "facebook/bart-large-mnli") #load_classifier()
|
| 36 |
# Define candidate genres
|
| 37 |
candidate_labels =["Romance", "Mystery", "Thriller", "Science Fiction", "Fantasy", "Horror", "Historical Fiction", "Crime", "Western", "Dystopian", "Biography", "Autobiography", "Memoir", "History", "Self-Help", "Travel", "Essay", "Journalism", "Sonnet", "Haiku", "Free Verse", "Narrative Poetry", "Lyric Poetry", "Tragedy", "Comedy", "Melodrama", "Farce", "Graphic Novel", "Epistolary", "Magical Realism", "Satire", "Young Adult Fiction"]
|
| 38 |
# Perform zero-shot classification
|
| 39 |
-
result = classifier(text[:1000], candidate_labels) #[:1000]), candidate_labels, multi_label=True)
|
| 40 |
genres = sorted(zip(result["labels"], result["scores"]), key=lambda x: x[1], reverse=Truest.subheader("Top 20 Detected Genres:"))
|
| 41 |
top_genres = genres[:20]
|
| 42 |
for genre, score in top_genres:
|
|
|
|
| 31 |
st.write("Processing the PDF...")
|
| 32 |
text = extract_text_from_pdf(pdf_file)
|
| 33 |
if text.strip():
|
| 34 |
+
st.write("PDF Text Extracted. Predicting the Genres...")
|
| 35 |
classifier = pipeline("zero-shot-classification", model = "facebook/bart-large-mnli") #load_classifier()
|
| 36 |
# Define candidate genres
|
| 37 |
candidate_labels =["Romance", "Mystery", "Thriller", "Science Fiction", "Fantasy", "Horror", "Historical Fiction", "Crime", "Western", "Dystopian", "Biography", "Autobiography", "Memoir", "History", "Self-Help", "Travel", "Essay", "Journalism", "Sonnet", "Haiku", "Free Verse", "Narrative Poetry", "Lyric Poetry", "Tragedy", "Comedy", "Melodrama", "Farce", "Graphic Novel", "Epistolary", "Magical Realism", "Satire", "Young Adult Fiction"]
|
| 38 |
# Perform zero-shot classification
|
| 39 |
+
result = classifier(text[:1000], candidate_labels, multi_label=True) #[:1000]), candidate_labels, multi_label=True)
|
| 40 |
genres = sorted(zip(result["labels"], result["scores"]), key=lambda x: x[1], reverse=Truest.subheader("Top 20 Detected Genres:"))
|
| 41 |
top_genres = genres[:20]
|
| 42 |
for genre, score in top_genres:
|