some work done on the running of the model

This commit is contained in:
2024-03-06 23:33:54 +00:00
parent 30c5b57378
commit 4a95f0211d
17 changed files with 360 additions and 121 deletions

View File

@@ -8,7 +8,12 @@
let file: File | undefined = $state();
let result: string | undefined = $state();
type Result = {
class: string,
confidence: number,
}
let _result: Promise<Result | undefined> = $state(new Promise(() => {}));
let run = $state(false);
let messages: MessageSimple;
@@ -25,7 +30,8 @@
run = true;
try {
result = await postFormData('models/run', form);
_result = await postFormData('models/run', form);
console.log(await _result);
} catch (e) {
if (e instanceof Response) {
messages.display(await e.json());
@@ -60,19 +66,21 @@
Run
</button>
{#if run}
{#if !result}
<div class="result">
<h1>
The class was not found
</h1>
</div>
{:else}
<div>
<h1>
Result
</h1>
The image was classified as {result}
</div>
{/if}
{#await _result then result}
{#if !result}
<div class="result">
<h1>
The class was not found
</h1>
</div>
{:else}
<div>
<h1>
Result
</h1>
The image was classified as {result.class} with confidence: {result.confidence}
</div>
{/if}
{/await}
{/if}
</form>