Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,2 @@
|
|
1 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
|
5 |
-
# DialoGPT Modell und Tokenizer laden
|
6 |
-
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
|
7 |
-
model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium")
|
8 |
-
|
9 |
-
def chat_with_kiki_gpt(user_input):
|
10 |
-
# Benutzereingabe kodieren und Modellantwort generieren
|
11 |
-
input_ids = tokenizer.encode(user_input + tokenizer.eos_token, return_tensors='pt')
|
12 |
-
chat_history_ids = model.generate(input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id)
|
13 |
-
chat_output = tokenizer.decode(chat_history_ids[:, input_ids.shape[-1]:][0], skip_special_tokens=True)
|
14 |
-
|
15 |
-
return f"KIKI-GPT: {chat_output}"
|
16 |
-
|
17 |
-
# Gradio-Benutzeroberfläche
|
18 |
-
interface = gr.Interface(
|
19 |
-
fn=chat_with_kiki_gpt,
|
20 |
-
inputs=gr.inputs.Textbox(lines=5, placeholder="Type your message to KIKI-GPT here..."),
|
21 |
-
outputs=gr.outputs.Textbox(),
|
22 |
-
title="KIKI-GPT",
|
23 |
-
description="Welcome to KIKI-GPT - a project on Hugging Face Spaces using Microsoft's DialoGPT. One of the fastest and best performing models for robotics! Created by Keyvan Hardani. For inquiries, contact: [email protected].",
|
24 |
-
live=True
|
25 |
-
)
|
26 |
-
|
27 |
-
interface.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
gr.Interface.load("models/microsoft/DialoGPT-medium").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|