Skip to content

Commit

Permalink
allow set default example url
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanguage committed May 23, 2024
1 parent 8af3c0d commit f886b9e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
Binary file added public/images/test_fish_img2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions public/plugins/chatbot-extension.imjoy.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

<script lang="javascript">
const chatbot_url = "https://bioimage.io/chat/"
const ufish_url = "https://ufish-team.github.io/"
//const ufish_url = "http://localhost:5173/"
//const ufish_url = "https://ufish-team.github.io/"
const ufish_url = "http://localhost:5173/"
const utils_url = ufish_url + "/plugins/chatbot-utils.imjoy.html"
const py_console_url = "https://nanguage.github.io/web-python-console/"

Expand Down Expand Up @@ -58,9 +58,10 @@
client = await api.createWindow({
src: ufish_url,
name: "ufish",
w: 25, h: 8
w: 25, h: 6
});
}
client.setExampleImageUrl(ufish_url + "images/test_fish_img2.jpg")
return client
}

Expand Down Expand Up @@ -99,9 +100,9 @@
description: "Run U-FISH web client to detect spots in the image",
properties: {
"channel": {
type: "number",
type: "number | null",
description: "Channel to use",
default: 0,
default: null,
},
"pThreshold": {
type: "number",
Expand Down Expand Up @@ -140,7 +141,7 @@
"diameter": {
type: "number",
description: "Diameter of the cells",
default: 40,
default: 50,
},
"model_type": {
type: "string",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {

<template>
<v-app>
<v-app-bar color="info">
<v-app-bar color="info" v-if="!isPluginMode">
<template v-slot:prepend>
<v-app-bar-nav-icon
color="white"
Expand Down
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ async function createApi() {
return await window.app.ufish_py.get_input_image()
}

async function setExampleImageUrl(url: string) {
const runStore = useRunStore()
runStore.setExampleImageUrl(url)
}

return {
"run": async () => {await waitRunable()},
"setup": setup,
Expand All @@ -92,6 +97,7 @@ async function createApi() {
"predict": predict,
"fetchImage": fetchImage,
"getInputImage": getInputImage,
"setExampleImageUrl": setExampleImageUrl,
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/stores/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const useRunStore = defineStore("run", {
channel: null as (number | null),
pThreshold: 0.5,
viewEnhanced: true,
exampleImageUrl: "https://huggingface.co/datasets/NaNg/TestData/resolve/main/FISH_spots/MERFISH_1.tif",
}),
actions: {
async waitRunable() {
Expand Down Expand Up @@ -95,6 +96,9 @@ export const useRunStore = defineStore("run", {
this.channel = channel;
this.pThreshold = pThreshold;
this.viewEnhanced = viewEnhanced;
},
setExampleImageUrl(url: string) {
this.exampleImageUrl = url;
}
}
})
9 changes: 6 additions & 3 deletions src/views/PredictView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { useRunStore } from '@/stores/run';
export default {
setup() {
const modelUrl = window.location.origin + "/model/v1.0-alldata-ufish_c32.onnx"
const test_data_url = "https://huggingface.co/datasets/NaNg/TestData/resolve/main/FISH_spots/MERFISH_1.tif"
const running = ref(false)
const plugin = ref(null as any)
Expand Down Expand Up @@ -228,7 +227,7 @@ export default {
return
}
const data = await res.arrayBuffer()
const fileName = test_data_url.split('/').pop()
const fileName = url.split('/').pop()
const shape = await plugin.value.view_img_from_bytes(fileName, data)
runInfoText.value = `Image loaded, shape: ${shape}`
loadingData.value = false
Expand All @@ -240,7 +239,11 @@ export default {
}
}
const loadExample = () => loadFromUrl(test_data_url)
const loadExample = () => {
const store = useRunStore()
const test_data_url = store.exampleImageUrl
loadFromUrl(test_data_url)
}
async function download() {
downloadBlob(output.value.enhanced, "enhanced.tif", "image/tiff")
Expand Down

0 comments on commit f886b9e

Please sign in to comment.