Spaces:
Sleeping
Sleeping
Commit
·
574e443
1
Parent(s):
fac5e5d
fixed out of bounds error
Browse files
frontend/src/components/Recipe.jsx
CHANGED
|
@@ -32,7 +32,7 @@ const Recipe = ({
|
|
| 32 |
const initializeLayerRecipe = useCallback(() => {
|
| 33 |
const recipe = [];
|
| 34 |
for (let i = 0; i < numLayers; i++) {
|
| 35 |
-
recipe.push([[
|
| 36 |
}
|
| 37 |
setLayerRecipe(recipe);
|
| 38 |
}, [numLayers, setLayerRecipe]);
|
|
@@ -65,10 +65,10 @@ const Recipe = ({
|
|
| 65 |
const block = [...newRecipe[layerIndex][blockIndex]];
|
| 66 |
|
| 67 |
if (field === "model") {
|
| 68 |
-
block[0] = value;
|
| 69 |
-
block[1] = 1;
|
| 70 |
-
} else if (field === "sourceLayer") {
|
| 71 |
block[1] = value;
|
|
|
|
|
|
|
|
|
|
| 72 |
} else if (field === "percentage") {
|
| 73 |
block[2] = value / 100;
|
| 74 |
}
|
|
@@ -240,7 +240,7 @@ const Recipe = ({
|
|
| 240 |
{layer.map((block, blockIndex) => {
|
| 241 |
const blockId = getBlockId(layerIndex, blockIndex);
|
| 242 |
const isExpanded = expandedBlock === blockId;
|
| 243 |
-
const modelName = getModelName(block[
|
| 244 |
|
| 245 |
return (
|
| 246 |
<div key={blockIndex} className="relative">
|
|
@@ -257,7 +257,7 @@ const Recipe = ({
|
|
| 257 |
>
|
| 258 |
<span className="text-primary-600">{modelName}</span>
|
| 259 |
<span className="text-secondary-500">
|
| 260 |
-
L{block[
|
| 261 |
</span>
|
| 262 |
<span className="text-accent-600">
|
| 263 |
{Math.round(block[2] * 100)}%
|
|
@@ -291,7 +291,7 @@ const Recipe = ({
|
|
| 291 |
</label>
|
| 292 |
<Dropdown
|
| 293 |
selectedValue={modelOptions.find(
|
| 294 |
-
(opt) => opt.value === block[
|
| 295 |
)}
|
| 296 |
onSelect={(option) => {
|
| 297 |
updateBlock(
|
|
@@ -313,7 +313,7 @@ const Recipe = ({
|
|
| 313 |
Layer
|
| 314 |
</label>
|
| 315 |
<NumberInput
|
| 316 |
-
value={block[
|
| 317 |
onChange={(value) =>
|
| 318 |
updateBlock(
|
| 319 |
layerIndex,
|
|
@@ -324,7 +324,7 @@ const Recipe = ({
|
|
| 324 |
}
|
| 325 |
min={1}
|
| 326 |
max={
|
| 327 |
-
block[
|
| 328 |
? modelLayerCounts.model1 === "N/A"
|
| 329 |
? 1
|
| 330 |
: modelLayerCounts.model1
|
|
|
|
| 32 |
const initializeLayerRecipe = useCallback(() => {
|
| 33 |
const recipe = [];
|
| 34 |
for (let i = 0; i < numLayers; i++) {
|
| 35 |
+
recipe.push([[1, 0, 0.5]]);
|
| 36 |
}
|
| 37 |
setLayerRecipe(recipe);
|
| 38 |
}, [numLayers, setLayerRecipe]);
|
|
|
|
| 65 |
const block = [...newRecipe[layerIndex][blockIndex]];
|
| 66 |
|
| 67 |
if (field === "model") {
|
|
|
|
|
|
|
|
|
|
| 68 |
block[1] = value;
|
| 69 |
+
block[0] = 1;
|
| 70 |
+
} else if (field === "sourceLayer") {
|
| 71 |
+
block[0] = value;
|
| 72 |
} else if (field === "percentage") {
|
| 73 |
block[2] = value / 100;
|
| 74 |
}
|
|
|
|
| 240 |
{layer.map((block, blockIndex) => {
|
| 241 |
const blockId = getBlockId(layerIndex, blockIndex);
|
| 242 |
const isExpanded = expandedBlock === blockId;
|
| 243 |
+
const modelName = getModelName(block[1]);
|
| 244 |
|
| 245 |
return (
|
| 246 |
<div key={blockIndex} className="relative">
|
|
|
|
| 257 |
>
|
| 258 |
<span className="text-primary-600">{modelName}</span>
|
| 259 |
<span className="text-secondary-500">
|
| 260 |
+
L{block[0]}
|
| 261 |
</span>
|
| 262 |
<span className="text-accent-600">
|
| 263 |
{Math.round(block[2] * 100)}%
|
|
|
|
| 291 |
</label>
|
| 292 |
<Dropdown
|
| 293 |
selectedValue={modelOptions.find(
|
| 294 |
+
(opt) => opt.value === block[1]
|
| 295 |
)}
|
| 296 |
onSelect={(option) => {
|
| 297 |
updateBlock(
|
|
|
|
| 313 |
Layer
|
| 314 |
</label>
|
| 315 |
<NumberInput
|
| 316 |
+
value={block[0]}
|
| 317 |
onChange={(value) =>
|
| 318 |
updateBlock(
|
| 319 |
layerIndex,
|
|
|
|
| 324 |
}
|
| 325 |
min={1}
|
| 326 |
max={
|
| 327 |
+
block[1] === 0
|
| 328 |
? modelLayerCounts.model1 === "N/A"
|
| 329 |
? 1
|
| 330 |
: modelLayerCounts.model1
|