NimaZah commited on
Commit
4170ec6
1 Parent(s): b8128c4

Add application file

Browse files
Files changed (3) hide show
  1. Dockerfile +16 -0
  2. app.py +25 -0
  3. requirements.txt +2 -0
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.9
5
+
6
+ RUN useradd -m -u 1000 user
7
+
8
+ WORKDIR /app
9
+
10
+ COPY --chown=user ./requirements.txt requirements.txt
11
+
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
+
14
+ COPY --chown=user . /app
15
+
16
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Replace with your model's path
5
+ model_name = "NimaZahedinameghi/nimaAxolotl"
6
+
7
+ # Initialize the chat pipeline
8
+ chat_pipeline = pipeline("text-generation", model=model_name)
9
+
10
+ def chat_with_model(user_input):
11
+ # Generate a response from the model
12
+ response = chat_pipeline(user_input, max_length=100, do_sample=True, top_p=0.95, top_k=50)
13
+ return response[0]['generated_text']
14
+
15
+ # Create the Gradio interface
16
+ interface = gr.Interface(
17
+ fn=chat_with_model,
18
+ inputs=gr.inputs.Textbox(lines=7, placeholder="Enter your message here..."),
19
+ outputs="text",
20
+ title="Chat with Fine-tuned Model",
21
+ description="Interact with the fine-tuned chat model."
22
+ )
23
+
24
+ if __name__ == "__main__":
25
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ transformers