ramky1979 commited on
Commit
f6a1e93
·
verified ·
1 Parent(s): ef06e2c

Update app.py

Browse files

Updated the model.

Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -1,9 +1,9 @@
1
  import gradio as gr
2
- from transformers import AutoTokenizer, AutoModel
3
 
4
  # Load GraphCodeBERT model and tokenizer
5
  tokenizer = AutoTokenizer.from_pretrained("microsoft/graphcodebert-base")
6
- model = AutoModel.from_pretrained("microsoft/graphcodebert-base")
7
 
8
  # Define input and output interfaces
9
  input = gr.Textbox(lines=5, label="Input")
@@ -21,5 +21,16 @@ def use_graphcodebert(input):
21
  return output
22
 
23
  # Create and launch Gradio interface
24
- iface = gr.Interface(fn=use_graphcodebert, inputs=input, outputs=output)
 
 
 
 
 
 
 
 
 
 
 
25
  iface.launch()
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
 
4
  # Load GraphCodeBERT model and tokenizer
5
  tokenizer = AutoTokenizer.from_pretrained("microsoft/graphcodebert-base")
6
+ model = AutoModelForCausalLM.from_pretrained("microsoft/graphcodebert-base")
7
 
8
  # Define input and output interfaces
9
  input = gr.Textbox(lines=5, label="Input")
 
21
  return output
22
 
23
  # Create and launch Gradio interface
24
+ # Create and launch Gradio interface
25
+ iface = gr.Interface.from_pretrained( # Use from_pretrained instead of from_pipeline
26
+ fn=use_graphcodebert,
27
+ inputs=input,
28
+ outputs=output,
29
+ model=model, # Pass the model as a parameter
30
+ tokenizer=tokenizer, # Pass the tokenizer as a parameter
31
+ title="GraphCodeBERT Code Synthesis", # Add a title for the web app
32
+ description="Enter a natural language query and get a code snippet generated by GraphCodeBERT.", # Add a description for the web app
33
+ examples=[["create a function that returns the sum of two numbers"], ["sort a list of numbers in ascending order"]], # Add some examples for the input
34
+ theme="huggingface" # Choose a theme for the web app
35
+ )
36
  iface.launch()