whitphx HF staff commited on
Commit
1ad3151
·
verified ·
1 Parent(s): 8824324

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +21 -22
index.html CHANGED
@@ -21,36 +21,35 @@
21
  <gradio-lite>
22
  <gradio-file name="app.py" entrypoint>
23
  import gradio as gr
 
24
 
25
- from filters import as_gray
26
-
27
- def process(input_image):
28
- output_image = as_gray(input_image)
29
- return output_image
30
-
31
- demo = gr.Interface(
32
- process,
33
- "image",
34
- "image",
35
- examples=["lion.jpg", "logo.png"],
36
  )
37
 
38
- demo.launch()
39
- </gradio-file>
 
 
 
40
 
41
- <gradio-file name="filters.py">
42
- from skimage.color import rgb2gray
 
 
 
 
 
43
 
44
- def as_gray(image):
45
- return rgb2gray(image)
46
- </gradio-file>
47
 
48
- <gradio-file name="lion.jpg" url="https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/test_data/lion.jpg" />
49
- <gradio-file name="logo.png" url="https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png" />
50
 
51
  <gradio-requirements>
52
- # Same syntax as requirements.txt
53
- scikit-image
54
  </gradio-requirements>
55
  </gradio-lite>
56
  </body>
 
21
  <gradio-lite>
22
  <gradio-file name="app.py" entrypoint>
23
  import gradio as gr
24
+ from transformers_js_py import pipeline
25
 
26
+ generator = await pipeline(
27
+ "text-generation",
28
+ "onnx-community/Qwen2.5-0.5B-Instruct",
29
+ { "dtype": "q4", "device": "webgpu" }
 
 
 
 
 
 
 
30
  )
31
 
32
+ async def chat_response(message, history):
33
+ messages = [
34
+ { "role": "system", "content": "You are a great assistant." },
35
+ { "role": "user", "content": message }
36
+ ]
37
 
38
+ output = await generator(messages, {
39
+ "max_new_tokens": 256,
40
+ "do_sample": True,
41
+ "temperature": 0.3,
42
+ })
43
+ response = output[0]["generated_text"][-1]["content"]
44
+ return response
45
 
46
+ demo = gr.ChatInterface(chat_response, type="messages", autofocus=False)
 
 
47
 
48
+ demo.launch()
49
+ </gradio-file>
50
 
51
  <gradio-requirements>
52
+ transformers-js-py
 
53
  </gradio-requirements>
54
  </gradio-lite>
55
  </body>