Commit ·
966b73b
1
Parent(s): ea2d9f5
Sree
Browse files- app.py +40 -4
- app1.py +10 -0
- app2.py +46 -0
- push.sh +1 -1
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,10 +1,46 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load a GPT-Neo model fine-tuned for code generation
|
| 5 |
+
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
|
| 6 |
|
| 7 |
+
def generate_code(prompt):
|
| 8 |
+
# Generate code from the model
|
| 9 |
+
responses = generator(prompt, max_length=50, num_return_sequences=1, temperature=0.5)
|
| 10 |
+
return responses[0]['generated_text']
|
| 11 |
|
| 12 |
+
# Create a Gradio Interface
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=generate_code,
|
| 15 |
+
inputs=[gr.inputs.Textbox(lines=10, label="Type your code description here")],
|
| 16 |
+
outputs=[gr.outputs.Textbox(label="Generated Code")],
|
| 17 |
+
examples=[["Create a Python function to add two numbers"]],
|
| 18 |
+
)
|
| 19 |
|
| 20 |
+
# Run the interface
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
iface.launch()
|
| 23 |
+
|
| 24 |
+
#import gradio as gr
|
| 25 |
+
#from transformers import pipeline
|
| 26 |
+
|
| 27 |
+
# Load a small GPT model fine-tuned for Python code generation
|
| 28 |
+
#generator = pipeline('text-generation', model='microsoft/CodeGPT-small-py')
|
| 29 |
+
|
| 30 |
+
#def generate_code(prompt):
|
| 31 |
+
# # Generate code from the model
|
| 32 |
+
# responses = generator(prompt, max_length=150, num_return_sequences=1, temperature=0.5)
|
| 33 |
+
# return responses[0]['generated_text']
|
| 34 |
+
|
| 35 |
+
# Create a Gradio Interface
|
| 36 |
+
#iface = gr.Interface(
|
| 37 |
+
# fn=generate_code,
|
| 38 |
+
# inputs=[gr.inputs.Textbox(lines=10, label="Type your code description here")],
|
| 39 |
+
# outputs=[gr.outputs.Textbox(label="Generated Code")],
|
| 40 |
+
# examples=[["Define a Python function to calculate factorial."]],
|
| 41 |
+
#)
|
| 42 |
+
|
| 43 |
+
# Run the interface
|
| 44 |
+
#if __name__ == "__main__":
|
| 45 |
+
# iface.launch()
|
| 46 |
|
|
|
app1.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def greet(name):
|
| 5 |
+
return "Hello " + name
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 9 |
+
|
| 10 |
+
demo.launch()
|
app2.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load a GPT-Neo model fine-tuned for code generation
|
| 5 |
+
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
|
| 6 |
+
|
| 7 |
+
def generate_code(prompt):
|
| 8 |
+
# Generate code from the model
|
| 9 |
+
responses = generator(prompt, max_length=50, num_return_sequences=1, temperature=0.5)
|
| 10 |
+
return responses[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
# Create a Gradio Interface
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=generate_code,
|
| 15 |
+
inputs=[gr.inputs.Textbox(lines=10, label="Type your code description here")],
|
| 16 |
+
outputs=[gr.outputs.Textbox(label="Generated Code")],
|
| 17 |
+
examples=[["Create a Python function to add two numbers"]],
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Run the interface
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
iface.launch()
|
| 23 |
+
|
| 24 |
+
#import gradio as gr
|
| 25 |
+
#from transformers import pipeline
|
| 26 |
+
|
| 27 |
+
# Load a small GPT model fine-tuned for Python code generation
|
| 28 |
+
#generator = pipeline('text-generation', model='microsoft/CodeGPT-small-py')
|
| 29 |
+
|
| 30 |
+
#def generate_code(prompt):
|
| 31 |
+
# # Generate code from the model
|
| 32 |
+
# responses = generator(prompt, max_length=150, num_return_sequences=1, temperature=0.5)
|
| 33 |
+
# return responses[0]['generated_text']
|
| 34 |
+
|
| 35 |
+
# Create a Gradio Interface
|
| 36 |
+
#iface = gr.Interface(
|
| 37 |
+
# fn=generate_code,
|
| 38 |
+
# inputs=[gr.inputs.Textbox(lines=10, label="Type your code description here")],
|
| 39 |
+
# outputs=[gr.outputs.Textbox(label="Generated Code")],
|
| 40 |
+
# examples=[["Define a Python function to calculate factorial."]],
|
| 41 |
+
#)
|
| 42 |
+
|
| 43 |
+
# Run the interface
|
| 44 |
+
#if __name__ == "__main__":
|
| 45 |
+
# iface.launch()
|
| 46 |
+
|
push.sh
CHANGED
|
@@ -5,4 +5,4 @@ git add .
|
|
| 5 |
git commit -m Sree
|
| 6 |
git push
|
| 7 |
|
| 8 |
-
echo
|
|
|
|
| 5 |
git commit -m Sree
|
| 6 |
git push
|
| 7 |
|
| 8 |
+
echo https://schogini-test1.hf.space
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
gradio
|
| 2 |
#==3.1.4
|
| 3 |
-
|
|
|
|
| 4 |
#huggingface_hub==0.19.0
|
|
|
|
| 1 |
gradio
|
| 2 |
#==3.1.4
|
| 3 |
+
transformers
|
| 4 |
+
#==4.20.1
|
| 5 |
#huggingface_hub==0.19.0
|