mkoot007 commited on
Commit
5ed8c71
β€’
1 Parent(s): 7f78171

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -57
app.py CHANGED
@@ -1,53 +1,6 @@
1
- # import gradio as gr
2
- # from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
3
-
4
- # tokenizer = BlenderbotTokenizer.from_pretrained("facebook/blenderbot-400M-distill")
5
- # model = BlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
6
-
7
- # def chat_with_model(input_text):
8
- # input_ids = tokenizer.encode("You: " + input_text, return_tensors="pt", max_length=512, truncation=True)
9
- # response_ids = model.generate(input_ids, max_length=100, num_return_sequences=1, no_repeat_ngram_size=2)
10
- # reply = tokenizer.decode(response_ids[0], skip_special_tokens=True)
11
- # return reply
12
-
13
- # iface = gr.Interface(
14
- # fn=chat_with_model,
15
- # inputs=gr.Textbox(prompt="You:"),
16
- # outputs=gr.Textbox(prompt="Bot:"),
17
- # title="Hello Mate!! 😁" ,
18
- # )
19
-
20
- # iface.launch()
21
-
22
-
23
-
24
-
25
  import gradio as gr
26
  from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
27
 
28
- DESCRIPTION = "This Application is developed just for Education purpose"
29
- LICENSE = "All Rights are Reserved to the Owner, Regards Mkoot"
30
- custom_css = """body {
31
- background-image: url('BK.jpg');
32
- background-size: cover;
33
- }
34
-
35
- input[type="text"] {
36
- background-color: #f2f2f2;
37
- color: #333;
38
- border: 1px solid #ccc;
39
- border-radius: 5px;
40
- }
41
-
42
- button {
43
- background-color: #007bff;
44
- color: #fff;
45
- border: none;
46
- border-radius: 5px;
47
- padding: 10px 20px;
48
- cursor: pointer;
49
- }"""
50
-
51
  tokenizer = BlenderbotTokenizer.from_pretrained("facebook/blenderbot-400M-distill")
52
  model = BlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
53
 
@@ -57,16 +10,15 @@ def chat_with_model(input_text):
57
  reply = tokenizer.decode(response_ids[0], skip_special_tokens=True)
58
  return reply
59
 
60
- with gr.Blocks(css=custom_css) as custom_css:
61
- gr.Markdown(DESCRIPTION)
62
- chat_interface = gr.Interface(
63
- fn=chat_with_model,
64
- inputs=gr.Textbox(prompt="You:"),
65
- outputs=gr.Textbox(prompt="Bot:"),
66
- title="Hello Mate!! 😁",
67
- )
68
- chat_interface.launch(share=True)
69
- gr.Markdown(LICENSE)
70
 
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  tokenizer = BlenderbotTokenizer.from_pretrained("facebook/blenderbot-400M-distill")
5
  model = BlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
6
 
 
10
  reply = tokenizer.decode(response_ids[0], skip_special_tokens=True)
11
  return reply
12
 
13
+ iface = gr.Interface(
14
+ fn=chat_with_model,
15
+ inputs=gr.Textbox(prompt="You:"),
16
+ outputs=gr.Textbox(prompt="Bot:"),
17
+ title="Hello Mate!! 😁" ,
18
+ )
19
+
20
+ iface.launch()
21
+
 
22
 
23
 
24