Spaces:
Running
Running
Update src/App.tsx
Browse files- src/App.tsx +40 -40
src/App.tsx
CHANGED
|
@@ -1,40 +1,40 @@
|
|
| 1 |
-
import MultiSourceCaptioningView from "./components/MultiSourceCaptioningView";
|
| 2 |
-
import { useVLMContext } from "./context/useVLMContext";
|
| 3 |
-
import { useState } from "react";
|
| 4 |
-
|
| 5 |
-
export default function App() {
|
| 6 |
-
const { isLoaded, isLoading, error, loadModel } = useVLMContext();
|
| 7 |
-
const [started, setStarted] = useState(false);
|
| 8 |
-
|
| 9 |
-
const handleLoadModel = async () => {
|
| 10 |
-
try {
|
| 11 |
-
await loadModel();
|
| 12 |
-
setStarted(true);
|
| 13 |
-
} catch (e) {
|
| 14 |
-
// error is handled by context
|
| 15 |
-
}
|
| 16 |
-
};
|
| 17 |
-
|
| 18 |
-
if (!started || !isLoaded) {
|
| 19 |
-
return (
|
| 20 |
-
<div className="flex flex-col items-center justify-center h-screen bg-gray-900 text-white">
|
| 21 |
-
<h1 className="text-2xl font-bold mb-4">FastVLM WebGPU</h1>
|
| 22 |
-
<button
|
| 23 |
-
className="px-6 py-3 rounded-lg bg-blue-600 text-white font-semibold text-lg mb-4"
|
| 24 |
-
onClick={handleLoadModel}
|
| 25 |
-
disabled={isLoading}
|
| 26 |
-
>
|
| 27 |
-
{isLoading ? "Loading Model..." : "Load Model"}
|
| 28 |
-
</button>
|
| 29 |
-
{error && <div className="text-red-400 mt-2">Model error: {error}</div>}
|
| 30 |
-
</div>
|
| 31 |
-
);
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
return (
|
| 35 |
-
<div className="App relative h-screen overflow-hidden">
|
| 36 |
-
<div className="absolute inset-0 bg-gray-900" />
|
| 37 |
-
<MultiSourceCaptioningView />
|
| 38 |
-
</div>
|
| 39 |
-
);
|
| 40 |
-
}
|
|
|
|
| 1 |
+
import MultiSourceCaptioningView from "./components/MultiSourceCaptioningView";
|
| 2 |
+
import { useVLMContext } from "./context/useVLMContext";
|
| 3 |
+
import { useState } from "react";
|
| 4 |
+
|
| 5 |
+
export default function App() {
|
| 6 |
+
const { isLoaded, isLoading, error, loadModel } = useVLMContext();
|
| 7 |
+
const [started, setStarted] = useState(false);
|
| 8 |
+
|
| 9 |
+
const handleLoadModel = async () => {
|
| 10 |
+
try {
|
| 11 |
+
await loadModel();
|
| 12 |
+
setStarted(true);
|
| 13 |
+
} catch (e) {
|
| 14 |
+
// error is handled by context
|
| 15 |
+
}
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
if (!started || !isLoaded) {
|
| 19 |
+
return (
|
| 20 |
+
<div className="flex flex-col items-center justify-center h-screen bg-gray-900 text-white">
|
| 21 |
+
<h1 className="text-2xl font-bold mb-4">FastVLM+Yolov8n WebGPU</h1>
|
| 22 |
+
<button
|
| 23 |
+
className="px-6 py-3 rounded-lg bg-blue-600 text-white font-semibold text-lg mb-4"
|
| 24 |
+
onClick={handleLoadModel}
|
| 25 |
+
disabled={isLoading}
|
| 26 |
+
>
|
| 27 |
+
{isLoading ? "Loading Model..." : "Load Model"}
|
| 28 |
+
</button>
|
| 29 |
+
{error && <div className="text-red-400 mt-2">Model error: {error}</div>}
|
| 30 |
+
</div>
|
| 31 |
+
);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return (
|
| 35 |
+
<div className="App relative h-screen overflow-hidden">
|
| 36 |
+
<div className="absolute inset-0 bg-gray-900" />
|
| 37 |
+
<MultiSourceCaptioningView />
|
| 38 |
+
</div>
|
| 39 |
+
);
|
| 40 |
+
}
|