Fluospark128 commited on
Commit
2d55565
·
verified ·
1 Parent(s): adcf74b

Update app.py

Browse files

Hmmm... Almost done😫

Files changed (1) hide show
  1. app.py +2 -2
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. Performing Genre Classification...")
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: