Ajay12345678980 commited on
Commit
a22cc41
·
verified ·
1 Parent(s): fe4e841

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -1,11 +1,14 @@
 
 
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- # Load the model using the Hugging Face pipeline
5
- model = pipeline("text-generation", model="Ajay12345678980/QA_bot")
6
 
7
- import re
8
- import torch
 
9
 
10
  # Define the prediction function
11
  def predict(text):
@@ -45,4 +48,3 @@ interface = gr.Interface(
45
  # Launch the Gradio app
46
  if __name__ == "__main__":
47
  interface.launch()
48
-
 
1
+ import re
2
+ import torch
3
  import gradio as gr
4
+ from transformers import GPT2LMHeadModel, GPT2Tokenizer
5
 
6
+ # Load the model and tokenizer from Hugging Face repository
7
+ model_repo_id = "Ajay12345678980/QA_bot" # Your model repository
8
 
9
+ # Initialize the model and tokenizer
10
+ model = GPT2LMHeadModel.from_pretrained(model_repo_id)
11
+ tokenizer = GPT2Tokenizer.from_pretrained(model_repo_id)
12
 
13
  # Define the prediction function
14
  def predict(text):
 
48
  # Launch the Gradio app
49
  if __name__ == "__main__":
50
  interface.launch()