lori0330 commited on
Commit
843fc81
1 Parent(s): 2e8ce81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -3,9 +3,8 @@ from transformers import pipeline
3
  import torch
4
  from diffusers import DiffusionPipeline
5
 
6
-
7
-
8
  def main():
 
9
  classifier = pipeline("text-classification", model="lori0330/BART_FineTuned_ZeroShotClassification")
10
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
11
  painter = DiffusionPipeline.from_pretrained(
@@ -15,10 +14,12 @@ def main():
15
  )
16
  painter.to('cuda')
17
 
 
18
  st.title("Brief Report Generator")
19
  st.write("Copy the text here:")
20
  user_input = st.text_input("")
21
-
 
22
  if user_input:
23
  result_1 = classifier(user_input)
24
  label = result_1[0]['label']
@@ -26,6 +27,7 @@ def main():
26
 
27
  result_2 = summarizer(user_input, max_length=100, min_length=30, do_sample=False)
28
  summary = result_2[0]['summary_text']
 
29
 
30
  description = f"This is mainly about {label}: {summary}"
31
  negative_prompt = "nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract]"
@@ -39,6 +41,7 @@ def main():
39
  num_inference_steps=28
40
  ).images[0]
41
 
 
42
  st.image(image)
43
 
44
  if __name__ == "__main__":
 
3
  import torch
4
  from diffusers import DiffusionPipeline
5
 
 
 
6
  def main():
7
+ # Prepare pipeline
8
  classifier = pipeline("text-classification", model="lori0330/BART_FineTuned_ZeroShotClassification")
9
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
10
  painter = DiffusionPipeline.from_pretrained(
 
14
  )
15
  painter.to('cuda')
16
 
17
+ # Edit the space
18
  st.title("Brief Report Generator")
19
  st.write("Copy the text here:")
20
  user_input = st.text_input("")
21
+
22
+ # Check input
23
  if user_input:
24
  result_1 = classifier(user_input)
25
  label = result_1[0]['label']
 
27
 
28
  result_2 = summarizer(user_input, max_length=100, min_length=30, do_sample=False)
29
  summary = result_2[0]['summary_text']
30
+ st.write(f"The summary of this text:\n{summary}")
31
 
32
  description = f"This is mainly about {label}: {summary}"
33
  negative_prompt = "nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract]"
 
41
  num_inference_steps=28
42
  ).images[0]
43
 
44
+ st.write(f"The attached image:\n")
45
  st.image(image)
46
 
47
  if __name__ == "__main__":