gradio-lite-image / index.html
abidlabs's picture
abidlabs HF staff
Update index.html
c52f02e
raw
history blame
No virus
1.11 kB
<!DOCTYPE html>
<html>
<head>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite@0.4.1/dist/lite.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite@0.4.1/dist/lite.css" />
</head>
<body>
<h2>Gradio-lite (Gradio running entirely in your browser!)</h2>
<p>Try it out! Once the Gradio app loads (can take 10-15 seconds), disconnect your Wifi and the machine learning model will still work!</p>
<gradio-lite>
<gradio-requirements>
transformers_js_py
</gradio-requirements>
<gradio-file name="app.py" entrypoint>
from transformers_js import import_transformers_js
import gradio as gr
transformers = await import_transformers_js()
pipeline = transformers.pipeline
pipe = await pipeline('zero-shot-image-classification')
async def transcribe(text):
data = await pipe(text)
result = [{item['label']: round(item['score'], 2) for item in data}]
return result
demo = gr.Interface(transcribe, [gr.Image("Input Image"), gr.Textbox(label="Classes")], gr.Label())
demo.launch()
</gradio-file>
</gradio-lite>
</body>
</html>