fix spacing and ; to be consistent, fix dup import
This commit is contained in:
Родитель
c46c1e9430
Коммит
0878e0575e
|
@ -1,7 +1,7 @@
|
|||
import {useRef, useState} from 'react';
|
||||
import {IMAGE_URLS} from '../data/sample-image-urls';
|
||||
import { inferenceSqueezenet } from '../utils/predict'
|
||||
import styles from '../styles/Home.module.css'
|
||||
import { useRef, useState } from 'react';
|
||||
import { IMAGE_URLS } from '../data/sample-image-urls';
|
||||
import { inferenceSqueezenet } from '../utils/predict';
|
||||
import styles from '../styles/Home.module.css';
|
||||
|
||||
interface Props {
|
||||
height: number;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { NextPage } from 'next'
|
||||
import Head from 'next/head'
|
||||
import styles from '../styles/Home.module.css'
|
||||
import type { NextPage } from 'next';
|
||||
import Head from 'next/head';
|
||||
import styles from '../styles/Home.module.css';
|
||||
import ImageCanvas from "../components/ImageCanvas";
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import Jimp from 'jimp/*';
|
||||
import * as Jimp from 'jimp';
|
||||
import { Tensor } from 'onnxruntime-web';
|
||||
const jimp = require('jimp');
|
||||
|
||||
export default async function getImageTensorFromPath(path: string, dims: number[] = [1, 3, 224, 224]): Promise<Tensor> {
|
||||
export async function getImageTensorFromPath(path: string, dims: number[] = [1, 3, 224, 224]): Promise<Tensor> {
|
||||
// 1. load the image
|
||||
var image = await loadImagefromPath(path, dims[2], dims[3]);
|
||||
// 2. convert to tensor
|
||||
|
@ -13,7 +12,7 @@ export default async function getImageTensorFromPath(path: string, dims: number[
|
|||
|
||||
async function loadImagefromPath(path: string, width: number = 224, height: number= 224): Promise<Jimp> {
|
||||
// Use Jimp to load the image and resize it.
|
||||
var imageData = await jimp.default.read(path).then((imageBuffer: Jimp) => {
|
||||
var imageData = await Jimp.default.read(path).then((imageBuffer: Jimp) => {
|
||||
return imageBuffer.resize(width, height)
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as ort from 'onnxruntime-web';
|
||||
import _ from 'lodash';
|
||||
import {imagenetClasses} from '../data/imagenet';
|
||||
import { InferenceSession } from 'onnxruntime-web';
|
||||
import { imagenetClasses } from '../data/imagenet';
|
||||
|
||||
export async function runSqueezenetModel(preprocessedData: any): Promise<[any, number]> {
|
||||
|
||||
|
@ -20,7 +19,7 @@ import { InferenceSession } from 'onnxruntime-web';
|
|||
}
|
||||
|
||||
|
||||
async function runInference(session: InferenceSession, preprocessedData: any): Promise<[any, number]> {
|
||||
async function runInference(session: ort.InferenceSession, preprocessedData: any): Promise<[any, number]> {
|
||||
|
||||
// Get start time to calculate inference time.
|
||||
const start = new Date();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Language: typescript
|
||||
// Path: react-next\utils\predict.ts
|
||||
import getImageTensorFromPath from './imageHelper';
|
||||
import {runSqueezenetModel} from './modelHelper';
|
||||
import { getImageTensorFromPath } from './imageHelper';
|
||||
import { runSqueezenetModel } from './modelHelper';
|
||||
|
||||
export async function inferenceSqueezenet(path: string): Promise<[any,number]> {
|
||||
// 1. Convert image to tensor
|
||||
|
|
Загрузка…
Ссылка в новой задаче