raja5259 commited on
Commit
83ed340
·
verified ·
1 Parent(s): 53a48bb

update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -37
app.py CHANGED
@@ -1,30 +1,5 @@
1
-
2
- import torch
3
- import RohanGivenCode
4
- from RohanGivenCode import *
5
-
6
-
7
- save1_or_load0 = 0 # 1 => Save; 0 => Load
8
-
9
- device = 'cpu'
10
- if torch.cuda.is_available():
11
- device = 'cuda'
12
- elif hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
13
- device = "mps"
14
- print(f"using device: {device}")
15
-
16
- # SEED
17
- torch.manual_seed(1337)
18
- if torch.cuda.is_available():
19
- torch.cuda.manual_seed(1337)
20
-
21
- # STOP
22
- # num_return_sequences = 5
23
- # max_length = 30
24
-
25
-
26
  import gradio as gr
27
- def sentence_builder(txt, new_tokens, ret_seq):
28
  txt_len = len(txt.split())
29
  if(txt_len < 9): # To make up minumum requirement of 9 words
30
  txt += " My lord, I claim your gift, my due by promise"
@@ -48,8 +23,8 @@ demo = gr.Interface(
48
  label="Number of Return Sequences",
49
  info="Choose how many return sequences are required in output.",
50
  value="5"
51
- ),
52
- gr.Textbox("", label = "Input",
53
  info="Give 8 words atleast, not to get concatenated with default words to make up it's minimum requirement."
54
  )
55
  ],
@@ -57,15 +32,15 @@ demo = gr.Interface(
57
  gr.Textbox("", label = "Output")
58
  ],
59
  title="Shakespeare Drama Dialogue Mimick by GPT3",
60
- examples=[[
61
- "A horse! a horse! my kingdom for a horse!",
62
- "What’s In A Name? A Rose By Any Name Would Smell As Sweet",
63
- "If Music Be The Food Of Love, Play On",
64
- "Our Doubts Are Traitors And Make Us Lose The Good We Oft Might Win By Fearing To Attempt.",
65
- "All That Glitters Is Not Gold.",
66
- "Love All, Trust A Few, Do Wrong To None.",
67
- "Love Looks Not With The Eyes, But With The Mind; And Therefore Is Winged Cupid Painted Blind"
68
- ]]
69
  )
70
 
71
  demo.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ def sentence_builder(new_tokens, ret_seq, txt):
3
  txt_len = len(txt.split())
4
  if(txt_len < 9): # To make up minumum requirement of 9 words
5
  txt += " My lord, I claim your gift, my due by promise"
 
23
  label="Number of Return Sequences",
24
  info="Choose how many return sequences are required in output.",
25
  value="5"
26
+ ),
27
+ gr.Textbox("", label = "Input",
28
  info="Give 8 words atleast, not to get concatenated with default words to make up it's minimum requirement."
29
  )
30
  ],
 
32
  gr.Textbox("", label = "Output")
33
  ],
34
  title="Shakespeare Drama Dialogue Mimick by GPT3",
35
+ examples=[
36
+ ["30", "5", "A horse! a horse! my kingdom for a horse!"],
37
+ ["30", "5", "What’s In A Name? A Rose By Any Name Would Smell As Sweet"],
38
+ ["30", "5", "If Music Be The Food Of Love, Play On"],
39
+ ["30", "5", "Our Doubts Are Traitors And Make Us Lose The Good We Oft Might Win By Fearing To Attempt."],
40
+ ["30", "5", "All That Glitters Is Not Gold."],
41
+ ["30", "5", "Love All, Trust A Few, Do Wrong To None."],
42
+ ["30", "5", "Love Looks Not With The Eyes, But With The Mind; And Therefore Is Winged Cupid Painted Blind"]
43
+ ]
44
  )
45
 
46
  demo.launch(debug=True)