Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
-
from huggingface_hub import InferenceClient
|
3 |
from gradio_client import Client, handle_file
|
4 |
|
5 |
-
# Gradio Client
|
6 |
client = Client("vikhyatk/moondream2")
|
7 |
|
8 |
-
#
|
9 |
def describe_image(image):
|
10 |
result = client.predict(
|
11 |
img=handle_file(image),
|
@@ -46,18 +45,15 @@ def respond(
|
|
46 |
# Kullanıcı mesajını ekle
|
47 |
messages.append({"role": "user", "content": message})
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
messages,
|
53 |
max_tokens=max_tokens,
|
54 |
-
stream=True,
|
55 |
temperature=temperature,
|
56 |
-
top_p=top_p
|
57 |
-
)
|
58 |
-
|
59 |
-
|
60 |
-
yield response
|
61 |
|
62 |
# Gradio app arayüzünü oluştur
|
63 |
demo = gr.Interface(
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from gradio_client import Client, handle_file
|
3 |
|
4 |
+
# Gradio Client ile model yükle
|
5 |
client = Client("vikhyatk/moondream2")
|
6 |
|
7 |
+
# Resim açıklamasını almak için kullanılacak fonksiyon
|
8 |
def describe_image(image):
|
9 |
result = client.predict(
|
10 |
img=handle_file(image),
|
|
|
45 |
# Kullanıcı mesajını ekle
|
46 |
messages.append({"role": "user", "content": message})
|
47 |
|
48 |
+
# Modelden gelen yanıtı al
|
49 |
+
response = client.chat(
|
50 |
+
messages=messages,
|
|
|
51 |
max_tokens=max_tokens,
|
|
|
52 |
temperature=temperature,
|
53 |
+
top_p=top_p
|
54 |
+
)
|
55 |
+
|
56 |
+
return response['choices'][0]['message']['content']
|
|
|
57 |
|
58 |
# Gradio app arayüzünü oluştur
|
59 |
demo = gr.Interface(
|