forked from rai-project/mlmodelscope
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* style transfer setup and icon updates * adding multi-input support * adding a few code comments * misc cleanup * Minor tweaks, multi-input still not working * finished styling for Style Transfer Output * Updates to QuickOutput * fixed (probably) issue with selecting multiple inputs * Added multi-input via urls * small change to id in Quick Multi Input Tab Content * misc cleanup * minor text updates * misc cleanup
- Loading branch information
1 parent
5de9d59
commit fc3ffdf
Showing
34 changed files
with
38,320 additions
and
102 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from "react"; | ||
import "./QuickImageInput.scss"; | ||
import Task from "../../../helpers/Task"; | ||
import useQuickInputControl from "./useQuickInputControl"; | ||
import useBEMNaming from "../../../common/useBEMNaming"; | ||
import { QuickMultiInputTabContent } from "./QuickMultiInputTabContent"; | ||
import { QuickInputTabTitle } from "./QuickInputTabTitle"; | ||
import {QuickInputType} from "./quickInputType"; | ||
|
||
export default function QuickMultiInput(props) { | ||
const { | ||
tabIsSelected, | ||
selectedInputs, | ||
addInput, | ||
getTabs, | ||
removeInput, | ||
selectTab, | ||
selectInput, | ||
runModel, | ||
} = useQuickInputControl(props); | ||
const { getBlock, getElement } = useBEMNaming("quick-image-input"); | ||
|
||
const task = Task.getStaticTask(props.model.output.type); | ||
// Note: This feels pretty hacky and TaskInputType/QuickInputType should probably be refactored? | ||
const tabs = getTabs(task.inputType.toLowerCase()); | ||
|
||
return ( | ||
<div className={getBlock()}> | ||
{!props.hideHeader && ( | ||
<> | ||
<h2 className={getElement("title")}>Try this model</h2> | ||
<div className={getElement("subtitle")}>{task.description}</div> | ||
</> | ||
)} | ||
<div className={getElement("tabs")}> | ||
<div className={getElement("tab-titles")} role="tablist"> | ||
{tabs.map((tab, index) => ( | ||
<QuickInputTabTitle | ||
key={index} | ||
tab={tab} | ||
index={index} | ||
tabIsSelected={tabIsSelected} | ||
selectTab={selectTab} | ||
getElement={getElement} | ||
/> | ||
))} | ||
</div> | ||
{tabs.map((tab, tabIndex) => ( | ||
<div key={tabIndex}> | ||
{task.inputs.map((input, inputIndex) => ( | ||
<QuickMultiInputTabContent | ||
key={inputIndex} | ||
tab={tab} | ||
tabIndex={tabIndex} | ||
getElement={getElement} | ||
{...props} | ||
removeInput={removeInput} | ||
addInput={addInput} | ||
selectInput={selectInput} | ||
tabIsSelected={tabIsSelected} | ||
selectedInputs={selectedInputs} | ||
input={input} | ||
inputIndex={inputIndex} | ||
/> | ||
))} | ||
</div> | ||
))} | ||
</div> | ||
<button | ||
className={getElement("run-model")} | ||
disabled={selectedInputs.length < task.inputs.length || selectedInputs[0] === ""} | ||
onClick={() => runModel()} | ||
> | ||
Run model and see results | ||
</button> | ||
</div> | ||
); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/components/Experiment/QuickInput/QuickMultiInputTabContent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react"; | ||
|
||
export function QuickMultiInputTabContent(props) { | ||
let {tabIndex, tab} = props; | ||
let Component = tab.component || (() => { | ||
return <div/> | ||
}); | ||
let className = 'tab'; | ||
if (props.tabIsSelected(tabIndex)) className += " tab--selected"; | ||
|
||
return ( | ||
<div | ||
key={tabIndex} | ||
className={props.getElement(className)} | ||
role="tabpanel" | ||
aria-labelledby={`${tab.id}`} | ||
id={`${tab.id}-panel-${props.inputIndex}`}> | ||
{/* Note: 'multiple' below refers to URL tab allowing multiple urls for a single input */} | ||
<Component | ||
multiple={props.multiple ?? false} | ||
addInput={props.addInput} | ||
removeInput={props.removeInput} | ||
inputSelected={props.selectInput} | ||
task={props.model.output.type} | ||
values={props.selectedInputs} {...tab.props} | ||
inputIndex={props.inputIndex} | ||
input={props.input} | ||
/> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.