Spaces:
Running
Running
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width" /> | |
<title>T5-base Language Translator</title> | |
<link rel="stylesheet" href="style.css" /> | |
</head> | |
<body> | |
<div class="card"> | |
<h1>Welcome to your static Space!</h1> | |
<h2 style="color: blue;">huggingface.js ν μ€νΈ νμ΄μ§</h2> | |
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p> | |
<p> | |
Also don't forget to check the | |
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>. | |
</p> | |
</div> | |
<br/><br/><br/><br/><br/> | |
<form id="hf-form"> | |
<!-- Hidden username field for accessibility --> | |
<input | |
type="text" | |
style="display:none" | |
autocomplete="username" | |
value="user" | |
/> | |
<div> | |
<label for="hf-token">Hugging Face Token (optional but limited if absent)</label> | |
<input | |
id="hf-token" | |
placeholder="HF-TOKEN" | |
type="password" | |
autocomplete="new-password" | |
/> | |
</div> | |
<input type="submit" value="Translate"/> | |
</form> | |
<script type="module"> | |
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm'; | |
document.getElementById('hf-form').addEventListener('submit', async (event) => { | |
event.preventDefault(); | |
const token = document.getElementById('hf-token').value; | |
const hf = new HfInference(token); | |
// You can also omit "model" to use the recommended model for the task | |
const result = await hf.translation({ | |
model: 't5-base', | |
inputs: 'My name is Wolfgang and I live in Amsterdam', | |
}); | |
console.log(result); | |
}); | |
</script> | |
</body> | |
</html> | |