schoginitoys commited on
Commit
bcb6ef0
1 Parent(s): 43cecc6
Files changed (3) hide show
  1. app.py +23 -0
  2. note.txt +23 -0
  3. push.sh +8 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load a small GPT model fine-tuned for Python code generation
5
+ generator = pipeline('text-generation', model='microsoft/CodeGPT-small-py')
6
+
7
+ def generate_code(prompt):
8
+ # Generate code from the model
9
+ responses = generator(prompt, max_length=150, 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.Textbox(lines=10, label="Type your code description here")],
16
+ outputs=[gr.Textbox(label="Generated Code")],
17
+ examples=[["Define a Python function to calculate factorial."]],
18
+ )
19
+
20
+ # Run the interface
21
+ if __name__ == "__main__":
22
+ iface.launch()
23
+
note.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 🚀 Get started with your gradio Space!
2
+ Your new space has been created, follow these steps to get started (or read our full documentation )
3
+
4
+ Start by cloning this repo by using:
5
+
6
+ git clone git@hf.co:spaces/schogini/test2
7
+ Create your Gradio app.py file:
8
+
9
+ import gradio as gr
10
+
11
+ def greet(name):
12
+ return "Hello " + name + "!!"
13
+
14
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
15
+ iface.launch()
16
+ Then commit and push:
17
+
18
+ git add app.py
19
+ git commit -m "Add application file"
20
+ git push
21
+ (Hint: Create the app.py file right in your browser alternatively)
22
+
23
+ 🤗 Your app should be running on this page after a few moments !
push.sh ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ #pip install --upgrade huggingface_hub
3
+
4
+ git add .
5
+ git commit -m Sree
6
+ git push
7
+
8
+ echo https://schogini-test1.hf.space