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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -37,7 +37,8 @@ if pdf_file is not None:
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:
43
  st.write(f"**{genre.capitalize()}**: {score:.2f}")
 
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=True)
41
+ st.subheader("Top 20 Detected Genres:")
42
  top_genres = genres[:20]
43
  for genre, score in top_genres:
44
  st.write(f"**{genre.capitalize()}**: {score:.2f}")