debashis2007 commited on
Commit
85b8aeb
·
1 Parent(s): 3e13784
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/AIML.iml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
.idea/misc.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Black">
4
+ <option name="sdkName" value="Python 3.12" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="Python 3.12" project-jdk-type="Python SDK">
7
+ <output url="file://$PROJECT_DIR$/out" />
8
+ </component>
9
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/AIML.iml" filepath="$PROJECT_DIR$/.idea/AIML.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
Gradio/Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /app
4
+ COPY requirements.txt ./
5
+ RUN pip install -r requirements.txt
6
+
7
+ COPY ./demo.py ./gr_demo.py /app/
8
+
9
+ CMD ["python", "-u", "demo.py"]
Gradio/README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # gradio-example
2
+
3
+ This repository demonstrates the deployment of [Gradio](https://gradio.app) applications using [transformer models](https://huggingface.co/transformers/).
4
+
5
+ It includes two examples: `demo.py` which employs transformer models, and `gr_demo.py`, the base gradio example from the [quickstart guide](https://gradio.app/quickstart/). To use a specific file, change the `demo.py` text in the `CMD ["python", "-u", "demo.py"]` command to the desired file.
6
+
7
+ ## Prerequisites
8
+
9
+ - Docker
10
+
11
+ ## Usage
12
+
13
+ 1. Clone this repository: `git clone https://github.com/arora-r/gradio-example.git`
14
+ 1. Navigate to the repository directory: `cd gradio-example`
15
+ 1. Build the Docker image: `docker build -t gradio-example .`
16
+ 1. Run the Docker container: `docker run -p 8080:8080 gradio-example`
17
+ 1. Open Gradio in your web browser: [http://localhost:8080](http://localhost:8080)
18
+
19
+ ## Customization
20
+
21
+ To use your own transformer models in the Gradio application, you can modify the `demo.py` file to import and utilize your model. Then, rebuild the Docker image and run the container as described above.
22
+
23
+ ## Acknowledgments
24
+
25
+ This repository was inspired by the examples in the [Gradio](https://github.com/gradio-app/gradio) repository, found [here](https://github.com/gradio-app/gradio/tree/main/demo).
Gradio/demo.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ model = pipeline("text-generation", model="gpt2")
5
+
6
+ def predict(prompt):
7
+ prediction = model(prompt)[0]["generated_text"]
8
+ return prediction
9
+
10
+ demo = gr.Interface(fn = predict,
11
+ inputs="text",
12
+ outputs="text")
13
+
14
+ demo.launch(server_name="0.0.0.0", server_port=8080)
Gradio/gr_demo.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def greet(name):
4
+ return "Hello " + name + "!"
5
+
6
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+
8
+ demo.launch()
Gradio/requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch
4
+ torchvision
requirements.txt CHANGED
@@ -1 +0,0 @@
1
- huggingface_hub==0.25.2