Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/model comparison #43

Merged
merged 21 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a64783f
Fix bug in InputPreviewImage component to display the correct selecte…
ShivanshShalabh Jul 30, 2024
81958b2
Debugged add models feature
ShivanshShalabh Aug 5, 2024
c7af5a2
Added src to adapt to new input formatting style
ShivanshShalabh Oct 1, 2024
ef4187b
Removed boiler loading page for comparision
ShivanshShalabh Nov 19, 2024
34a768e
Fixed just single model ouput for comparision, TODO: Fix InputSelector
ShivanshShalabh Nov 25, 2024
64bf288
Fixed InputSelector for single input and multi-input
ShivanshShalabh Nov 27, 2024
592fbd0
Fixed switching between inputs
ShivanshShalabh Dec 6, 2024
e696747
Fixed mutiple inputs bug
ShivanshShalabh Jan 7, 2025
a2af766
Refactor task retrieval in ExperimentDetailContainer and update navig…
ShivanshShalabh Jan 7, 2025
434bc08
Refactor input handling now supporting multiple inputs in model compa…
ShivanshShalabh Jan 10, 2025
60a8894
Added support for input handling and UI for multiple inputs in Experi…
ShivanshShalabh Jan 16, 2025
70ddfc7
Add className prop to MultiInputPreview for styling in InputSelectors
ShivanshShalabh Jan 16, 2025
8c71437
Fixed Add Model feature updating input handling and integrated task i…
ShivanshShalabh Jan 16, 2025
2ec19d8
Fixed duplicate inputs in the experiment
ShivanshShalabh Jan 16, 2025
3e90304
Add Webpack configuration for handling .mjs files with source-map-loader
ShivanshShalabh Jan 21, 2025
4ba81e0
Refactor runModels to run trial for each input when adding models
ShivanshShalabh Jan 21, 2025
985e5b0
Add title attribute to text previews for full input visibility
ShivanshShalabh Jan 21, 2025
4038a39
Fix input reference in MultiInputPreview for accurate text display
ShivanshShalabh Jan 24, 2025
71274ae
Remove unnecessary query string delimiter in experiment navigation links
ShivanshShalabh Jan 24, 2025
bca446e
Update styles for input selector buttons and document previews
ShivanshShalabh Jan 24, 2025
19f7535
Merge branch 'develop' into bug/model-comparison
ShivanshShalabh Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,3 +757,19 @@ module.exports = function (webpackEnv) {
performance: false,
};
};
module.exports = {
module: {
rules: [
{
test: /\.mjs$/,
resolve: {
fullySpecified: false,
},
...(isEnvDevelopment && {
use: ['source-map-loader'],
}),
exclude: /node_modules\/@mediapipe\/tasks-vision/,
},
],
},
};
5 changes: 4 additions & 1 deletion src/components/Experiment/QuickInput/useQuickInputControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ export default function useQuickInputControl(props) {
// Data to be sent to API
if (typeof url !== 'object') {
selectedData = [{ src: url, inputType: task.inputType }];
} else {
} else if (Array.isArray(url)) {
selectedData = url.map(u => ({ inputType: task.inputType, src: u }));
}
else {
selectedData = [{ inputType: task.inputType, ...url }];
}
}
Expand Down
47 changes: 24 additions & 23 deletions src/components/Experiment/QuickOutput/InputPreview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import "./InputPreview.scss";
import useBEMNaming from "../../../common/useBEMNaming";
import { ReactComponent as DocumentIcon } from "../../../resources/icons/icon-document.svg";
import CsvIcon from "../../../../src/resources/icons/icon-csv-file.svg";


const defaultProps = {
className: "input-preview",
input: "",
Expand All @@ -27,45 +27,46 @@ export default function InputPreview(givenProps) {
const getInput = () => {
switch (props.inputType) {
case "text":
return <p className={getElement("text")}>{props.input.src}</p>;
let shortened = props.input.src.split(" ").slice(0, 5).join(" ");
shortened = shortened + (shortened.length < props.input.src.length ? "..." : "");
return <p className={getElement("text")} title={props.input.src}>{shortened}</p>;
case "audio":
return <audio className={getElement("audio")} controls src={props.input.src} />;
return props.input?.src?.title ? <audio className={getElement("audio")} controls src={props.input.src.src} title={props.input.src.title} /> : <audio className={getElement("audio")} controls src={props.input.src} />;
case "image":
return <img className={getElement("image")} src={props.input.src} />;
case "video":
return <video className={getElement("video")} src={props.input.src} controls />;
case "document":
return <button className={getElement("document")}><DocumentIcon className='icon' /><a href={props.input.src} target='_blank' ><span>{props.input.description ?? "Document"}</span></a></button>;
case "csv":
return (
<>
<a
download="input.csv"
href={props.input[0].src}
className={getElement('csv')}
>
<a download="input.csv" href={props.input[0].src} className={getElement('csv')}>
<img src={CsvIcon} alt="download-csv-icon" />
<p>
Download
</p>
</a>
</>
)
<p>Download</p>
</a>
</>
);
default:
return <p>Not currently supported</p>;
}
};

return (
<div className={getBlock()}>
<h3 className={getElement("title")}>
Input {inputTypes[props.inputType]}
</h3>
{props?.experimentInputPreview ||
<h3 className={getElement("title")}>
Input {inputTypes[props.inputType]}
</h3>
}
{getInput()}
<button
className={getElement("back-button")}
onClick={props.onBackClicked}
>
Try a different {inputTypes[props.inputType]?.toLowerCase()}
</button>
{props?.experimentInputPreview ||
<button
className={getElement("back-button")}
onClick={props.onBackClicked}
>
Try a different {inputTypes[props.inputType]?.toLowerCase()}
</button>}
</div>
);
}
19 changes: 10 additions & 9 deletions src/components/Experiment/QuickOutput/MultiInputPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default function MultiInputPreview(givenProps) {

const getInputs = (input) => {
switch (input.inputType) {
case QuickInputType.Text:
return (
<p className={getElement("text")}>{input.src}</p>
);
case QuickInputType.Document:
case TaskInputTypes.Text:
let shortened = input.src.split(" ").slice(0, 5).join(" ");
shortened = shortened + (shortened.length < input.src.length ? "..." : "");
return <p className={getElement("text")} title={input.src}>{shortened}</p>;
case TaskInputTypes.Document:
return (
<button className={getElement("document")}>
<DocumentIcon className='icon' />
Expand Down Expand Up @@ -52,9 +52,9 @@ export default function MultiInputPreview(givenProps) {

return (
<div className={getBlock()}>
<h3 className={getElement("title")}>
{props.experimentInputPreview || <h3 className={getElement("title")}>
Inputs
</h3>
</h3>}
<div className={getElement("container")}>
{
props.inputs.length > 2 ? (
Expand Down Expand Up @@ -90,12 +90,13 @@ export default function MultiInputPreview(givenProps) {
}
</div>

<button
{props.experimentInputPreview || <button
className={getElement("back-button")}
onClick={props.onBackClicked}
>
Try different inputs
</button>
</button>}
</div>
);

}
3 changes: 2 additions & 1 deletion src/components/ExperimentDetails/ExperimentDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ExperimentDetailPage(props) {
return "33%";
};

let trialComponents = props.experiment.trials.map((trial, trialIndex) => (
let trialComponents = props.experiment.trials?.map((trial, trialIndex) => (
<div
style={{ width: calculateCardWidth() }}
key={trialIndex}
Expand Down Expand Up @@ -57,6 +57,7 @@ export default function ExperimentDetailPage(props) {
selectInput={props.updateInput}
getAddModelsLink={props.getAddModelsLink}
task={props.task}
hasMultipleInputs={props.hasMultipleInputs}
/>
<div className={getElement("scroll-container")}>
<div className={getElement("trial-cards")}>{trialComponents}</div>
Expand Down
9 changes: 1 addition & 8 deletions src/components/ExperimentDetails/ExperimentDetailPage.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import "../../App";

.experiment-detail-page {

&__sticky-bar {
position: fixed;
bottom: 0;
Expand All @@ -24,13 +23,12 @@
}
}


&__trial-cards {
display: flex;
flex-direction: row-reverse;
width: 100%;
max-width: 100%;
overflow-x: scroll;
overflow-x: auto;
background: $white;
padding: 20px 12px;
transform: rotate(180deg);
Expand All @@ -40,16 +38,12 @@
transform: none;
overflow-x: hidden;
align-items: center;


}

@include maxWidth(550px) {
padding-left: 0;
padding-right: 0;
}


}

&__trials-header {
Expand Down Expand Up @@ -91,7 +85,6 @@
margin-left: 0;
}


@include tabletWidth {
transform: none;
margin-left: 0;
Expand Down
48 changes: 20 additions & 28 deletions src/components/ExperimentDetails/Inputs/ExperimentInputs.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import useBEMNaming from "../../../common/useBEMNaming";
import React, { useEffect, useRef, useState } from "react";
import "./ExperimentInputs.scss";
import Button from "../../Buttons/Button";
import NoInputs from "./NoInputs";
import InputPreview from "./InputPreview";
import Button from "../../Buttons/Button"; import NoInputs from "./NoInputs";
import InputSelectors from "./InputSelectors";

export const ExperimentInputs = (props) => {
Expand All @@ -27,13 +25,13 @@ export const ExperimentInputs = (props) => {
};
}, [isOpen]);

const selectedIndex = props.inputs.indexOf(props.selectedInput);
const selectedIndex = props.selectedInput && (props.hasMultipleInputs ? props.inputs.indexOf(props.selectedInput) : props.inputs.findIndex(input => input.src === props.selectedInput.src));

const hasNoInputs = props.inputs.length === 0 || props.inputs[0] === "";
const hasNoInputs = !props.inputs || props.inputs.length === 0 || props.inputs[0] === "";

const handleSelect = (input) => {
const handleSelect = (input, idx) => {
setIsOpen(false);
props.selectInput(input);
props.selectInput(input, idx);
};

if (hasNoInputs)
Expand All @@ -42,33 +40,27 @@ export const ExperimentInputs = (props) => {
return (
<div className={getBlock()}>
<div ref={handlerRef} className={getElement("selection-area")}>
<InputPreview
toggleOpen={() => setIsOpen(!isOpen)}
selectedInput={props.selectedInput}

<Button
content={"Add model"}
icon="plus"
isPrimary={false}
isSmall={false}
link={props.getAddModelsLink(props)}
/>

<InputSelectors
inputs={props.inputs}
selectedIndex={selectedIndex}
isOpen={isOpen}
handleSelect={handleSelect}
showAddInputModal={props.showAddInputModal}
showDeleteInputModal={props.showDeleteInputModal}
task={props.task}
/>

{isOpen && (
<InputSelectors
inputs={props.inputs}
selectedIndex={selectedIndex}
handleSelect={handleSelect}
showAddInputModal={props.showAddInputModal}
showDeleteInputModal={props.showDeleteInputModal}
task={props.task}
/>
)}
</div>

<Button
content={"Add model"}
icon="plus"
isPrimary={false}
isSmall={false}
link={props.getAddModelsLink(props)}
/>

</div>
);
};
6 changes: 4 additions & 2 deletions src/components/ExperimentDetails/Inputs/ExperimentInputs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.experiment-inputs {
align-items: center;
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;

Expand All @@ -14,12 +15,13 @@

.secondary-button {
height: 48px;
margin-left: auto;
margin-bottom: 20px;
}

&__selection-area {
margin-bottom: 32px;
position: relative;
width: clamp(200px, 500px, 400px);
width: 100%;

@include tabletWidth {
max-width: 300px;
Expand Down
15 changes: 0 additions & 15 deletions src/components/ExperimentDetails/Inputs/InputPreview.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from "react";

export function InputPreviewImage(props) {
const { getElement } = useBEMNaming("input-preview");

return (
<button
className={getElement(
Expand Down
Loading