some work done on the running of the model
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user