arshad615 commited on
Commit
2a34a73
·
1 Parent(s): 78749bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -14,25 +14,37 @@ pipeline = transformers.pipeline(
14
  trust_remote_code=True,
15
  device_map="auto",
16
  )
17
- def generate_text(input_text):
18
- sequences = pipeline(
19
  "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",
20
  max_length=200,
21
  do_sample=True,
22
  top_k=10,
23
  num_return_sequences=1,
24
  eos_token_id=tokenizer.eos_token_id,
25
- )
26
- return sequences;
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
 
29
- gr.Interface(
30
- generate_text,
31
- inputs="text",
32
- outputs="text",
33
- title="Text Generation App",
34
- description="Generate text based on input.",
35
- ).launch()
36
 
37
  # def generate_text(input_text):
38
  # input_ids = tokenizer.encode(input_text, return_tensors="pt")
 
14
  trust_remote_code=True,
15
  device_map="auto",
16
  )
17
+ sequences = pipeline(
 
18
  "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",
19
  max_length=200,
20
  do_sample=True,
21
  top_k=10,
22
  num_return_sequences=1,
23
  eos_token_id=tokenizer.eos_token_id,
24
+ )
25
+
26
+ for seq in sequences:
27
+ print(f"Result: {seq['generated_text']}")
28
+
29
+ # def generate_text(input_text):
30
+ # sequences = pipeline(
31
+ # "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",
32
+ # max_length=200,
33
+ # do_sample=True,
34
+ # top_k=10,
35
+ # num_return_sequences=1,
36
+ # eos_token_id=tokenizer.eos_token_id,
37
+ # )
38
+ # return sequences;
39
 
40
 
41
+ # gr.Interface(
42
+ # generate_text,
43
+ # inputs="text",
44
+ # outputs="text",
45
+ # title="Text Generation App",
46
+ # description="Generate text based on input.",
47
+ # ).launch()
48
 
49
  # def generate_text(input_text):
50
  # input_ids = tokenizer.encode(input_text, return_tensors="pt")