|
|
|
|
|
|
|
import { Client } from "@gradio/client"; |
|
import fs from 'fs'; |
|
import path from 'path'; |
|
import { fileURLToPath } from 'url'; |
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url); |
|
const __dirname = path.dirname(__filename); |
|
|
|
const client = await Client.connect("http://0.0.0.0:7860/"); |
|
|
|
|
|
const imagePath = path.join(__dirname, 'large_cell_carcinoma_of_the_lung.jpg'); |
|
|
|
|
|
const exampleImage = fs.readFileSync(imagePath); |
|
|
|
|
|
const result = await client.predict("/predict", { |
|
image: new Blob([exampleImage]), |
|
}); |
|
|
|
console.log(result.data); |
|
|