Spaces:
Running
Running
Download src/Initialize.tsx from thuongvv/TranslateGemma-WebGPU: direct link, hf CLI and curl.
- Browser
- Download file 3.79 kB
-
https://huggingface.co/spaces/thuongvv/TranslateGemma-WebGPU/resolve/e734e02c73925afba1e916d53b3e0e6f38720bee/src/Initialize.tsx
- Command line
-
hf download hf://spaces/thuongvv/TranslateGemma-WebGPU@e734e02c73925afba1e916d53b3e0e6f38720bee/src/Initialize.tsx
-
curl -L -o Initialize.tsx https://huggingface.co/spaces/thuongvv/TranslateGemma-WebGPU/resolve/e734e02c73925afba1e916d53b3e0e6f38720bee/src/Initialize.tsx
3.79 kB
| import { Button } from "./theme"; | |
| import cn from "./utils/classnames.ts"; | |
| import { formatBytes } from "./utils/format.ts"; | |
| import Translator from "./ai/Translator.ts"; | |
| interface InitializeProps { | |
| progress: number; | |
| onInitialize: () => Promise<void>; | |
| isInitializing?: boolean; | |
| className?: string; | |
| } | |
| export default function Initialize({ | |
| progress, | |
| onInitialize, | |
| isInitializing = false, | |
| className = "", | |
| }: InitializeProps) { | |
| return ( | |
| <div className={cn("max-w-2xl mx-auto px-8", className)}> | |
| <div className="bg-white rounded-lg shadow-md p-8 border border-border"> | |
| <div className="flex flex-col items-center gap-6"> | |
| {/* Description */} | |
| <div className="space-y-4 text-left w-full"> | |
| <div> | |
| <h3 className="font-semibold text-base mb-1"> | |
| About TranslateGemma 4B | |
| </h3> | |
| <p className="text-sm text-secondary-foreground"> | |
| TranslateGemma is a family of translation models from Google, | |
| built on top of Gemma 2B. This 4B parameter model supports | |
| translations across 100+ languages with state-of-the-art | |
| quality.{" "} | |
| <a | |
| href="https://blog.google/innovation-and-ai/technology/developers-tools/translategemma/" | |
| target="_blank" | |
| rel="noopener noreferrer" | |
| className="text-primary hover:underline" | |
| > | |
| Learn more | |
| </a> | |
| </p> | |
| </div> | |
| <div> | |
| <h3 className="font-semibold text-base mb-1"> | |
| Completely private & offline-capable | |
| </h3> | |
| <p className="text-sm text-secondary-foreground"> | |
| Everything runs entirely in your browser with 🤗 Transformers.js | |
| and ONNX Runtime Web — no data is ever sent to a server. Once | |
| loaded, it works offline. | |
| </p> | |
| </div> | |
| <div> | |
| <h3 className="font-semibold text-base mb-1"> | |
| Experimental — WebGPU required | |
| </h3> | |
| <p className="text-sm text-secondary-foreground"> | |
| This is experimental and requires a browser with WebGPU support | |
| and enough VRAM to run the model. | |
| </p> | |
| </div> | |
| </div> | |
| {/* Initialize button or progress indicator */} | |
| {isInitializing ? ( | |
| <div className="w-full space-y-2"> | |
| <div className="flex justify-between items-center"> | |
| <span className="text-sm font-medium text-muted-foreground"> | |
| Loading model... | |
| </span> | |
| <span className="text-sm font-medium text-primary"> | |
| {progress}% | |
| </span> | |
| </div> | |
| <div className="w-full bg-muted rounded-full h-2 overflow-hidden"> | |
| <div | |
| className="bg-primary h-full transition-all duration-300 ease-out" | |
| style={{ width: `${progress}%` }} | |
| /> | |
| </div> | |
| <p className="text-xs text-muted-foreground text-center"> | |
| This may take a few moments. Please don't close the page. | |
| </p> | |
| </div> | |
| ) : ( | |
| <Button | |
| variant="primary" | |
| onClick={onInitialize} | |
| disabled={isInitializing} | |
| className="text-lg mt-8" | |
| > | |
| {isInitializing | |
| ? "Initializing..." | |
| : `Download TranslateGemma (${formatBytes(Translator.size)})`} | |
| </Button> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |