Update index.html
Browse files- index.html +23 -21
index.html
CHANGED
|
@@ -21,36 +21,38 @@
|
|
| 21 |
<gradio-lite>
|
| 22 |
<gradio-file name="app.py" entrypoint>
|
| 23 |
import gradio as gr
|
|
|
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
def process(input_image):
|
| 28 |
-
output_image = as_gray(input_image)
|
| 29 |
-
return output_image
|
| 30 |
|
| 31 |
-
|
| 32 |
-
process,
|
| 33 |
-
"image",
|
| 34 |
-
"image",
|
| 35 |
-
examples=["lion.jpg", "logo.png"],
|
| 36 |
-
)
|
| 37 |
|
| 38 |
-
demo.launch()
|
| 39 |
-
</gradio-file>
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
def as_gray(image):
|
| 45 |
-
return rgb2gray(image)
|
| 46 |
-
</gradio-file>
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
<gradio-requirements>
|
| 52 |
-
|
| 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 js import self
|
| 25 |
|
| 26 |
+
session = None
|
| 27 |
+
try:
|
| 28 |
+
can_ai_create = await self.ai.canCreateTextSession()
|
| 29 |
+
if can_ai_create != "no":
|
| 30 |
+
session = await self.ai.createTextSession()
|
| 31 |
+
except:
|
| 32 |
+
pass
|
| 33 |
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
self.ai_text_session = session
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
async def prompt(message, history):
|
| 39 |
+
session = self.ai_text_session
|
| 40 |
+
if not session:
|
| 41 |
+
raise Exception("Gemini Nano is not available in your browser.")
|
| 42 |
+
|
| 43 |
+
stream = session.promptStreaming(message)
|
| 44 |
+
async for chunk in stream:
|
| 45 |
+
yield chunk
|
| 46 |
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
demo = gr.ChatInterface(fn=prompt)
|
| 49 |
+
|
| 50 |
+
demo.launch()
|
| 51 |
+
|
| 52 |
+
</gradio-file>
|
| 53 |
|
| 54 |
<gradio-requirements>
|
| 55 |
+
transformers-js-py
|
|
|
|
| 56 |
</gradio-requirements>
|
| 57 |
</gradio-lite>
|
| 58 |
</body>
|