apolinario commited on
Commit
e127f89
·
1 Parent(s): d4fd92f

swtich views

Browse files
ui/src/app/jobs/new/SimplifiedJob.tsx CHANGED
@@ -42,6 +42,8 @@ type SimplifiedJobProps = {
42
  forceHFBackend?: boolean;
43
  datasetOptions: SelectOption[];
44
  namespace?: string | null;
 
 
45
  };
46
 
47
  const backendOptions = [
@@ -62,6 +64,8 @@ export default function SimplifiedJob({
62
  forceHFBackend = false,
63
  datasetOptions,
64
  namespace,
 
 
65
  }: SimplifiedJobProps) {
66
  const [showAdvanced, setShowAdvanced] = useState(false);
67
  const process = jobConfig.config.process[0];
@@ -93,7 +97,7 @@ export default function SimplifiedJob({
93
 
94
  const dataset = process.datasets?.[0] ?? objectCopy(defaultDatasetConfig);
95
 
96
- const [trainDatasetMode, setTrainDatasetMode] = useState<DatasetMode>(hasCustomTrainPath ? 'existing' : 'upload');
97
  const [trainModeTouched, setTrainModeTouched] = useState(hasCustomTrainPath);
98
  const [trainDatasetName, setTrainDatasetName] = useState(() =>
99
  slugify(jobConfig.config.name || 'training-data'),
@@ -108,9 +112,7 @@ export default function SimplifiedJob({
108
  const [trainUploadInfo, setTrainUploadInfo] = useState<string | null>(null);
109
  const [trainUploadError, setTrainUploadError] = useState<string | null>(null);
110
 
111
- const [controlDatasetMode, setControlDatasetMode] = useState<DatasetMode>(
112
- hasCustomControlPath ? 'existing' : 'upload',
113
- );
114
  const [controlModeTouched, setControlModeTouched] = useState(hasCustomControlPath);
115
  const [controlDatasetName, setControlDatasetName] = useState(() =>
116
  slugify(`${jobConfig.config.name || 'training'}-control`),
@@ -210,26 +212,22 @@ export default function SimplifiedJob({
210
  const effectiveBackendOptions = forceHFBackend ? backendOptions.filter(opt => opt.value === 'hf-jobs') : backendOptions;
211
 
212
  useEffect(() => {
213
- if (!trainModeTouched) {
214
- setTrainDatasetMode(hasCustomTrainPath ? 'existing' : 'upload');
215
- if (hasCustomTrainPath) {
216
- setTrainDatasetPath(process.datasets?.[0]?.folder_path ?? null);
217
- }
218
  }
219
- }, [hasCustomTrainPath, process.datasets, trainModeTouched]);
220
 
221
  useEffect(() => {
222
- if (!controlModeTouched) {
223
- setControlDatasetMode(hasCustomControlPath ? 'existing' : 'upload');
224
- if (hasCustomControlPath) {
225
- setControlDatasetPath(
226
- typeof process.datasets?.[0]?.control_path === 'string'
227
- ? (process.datasets?.[0]?.control_path as string)
228
- : null,
229
- );
230
- }
231
  }
232
- }, [hasCustomControlPath, process.datasets, controlModeTouched]);
233
 
234
  useEffect(() => {
235
  if (!trainDatasetNameTouched) {
@@ -525,12 +523,28 @@ export default function SimplifiedJob({
525
  </Button>
526
  </div>
527
  {showAdvanced && (
528
- <div className="mt-6 grid grid-cols-1 md:grid-cols-2 gap-6">
529
- <SelectInput
530
- label="Training Backend"
531
- value={trainingBackend}
532
- onChange={value => setTrainingBackend?.(value as 'local' | 'hf-jobs')}
533
- options={effectiveBackendOptions}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  disabled={forceHFBackend || !setTrainingBackend}
535
  />
536
  {trainingBackend === 'local' && (
@@ -565,17 +579,18 @@ export default function SimplifiedJob({
565
  { value: 'adafactor', label: 'Adafactor' },
566
  ]}
567
  />
568
- <div className="flex items-center gap-2 pt-2">
569
- <Checkbox
570
- label="Skip First Sample"
571
- checked={process.train.skip_first_sample}
572
- onChange={value => setJobConfig(value, 'config.process[0].train.skip_first_sample')}
573
- />
574
- <Checkbox
575
- label="Disable Sampling"
576
- checked={process.train.disable_sampling}
577
- onChange={value => setJobConfig(value, 'config.process[0].train.disable_sampling')}
578
- />
 
579
  </div>
580
  </div>
581
  )}
@@ -586,6 +601,11 @@ export default function SimplifiedJob({
586
  setTrainDatasetMode(value);
587
  setTrainModeTouched(true);
588
  })}
 
 
 
 
 
589
 
590
  {trainDatasetMode === 'upload' ? (
591
  <div className="space-y-4">
@@ -664,6 +684,9 @@ export default function SimplifiedJob({
664
  setControlDatasetMode(value);
665
  setControlModeTouched(true);
666
  })}
 
 
 
667
 
668
  {controlDatasetMode === 'upload' ? (
669
  <div className="space-y-4">
 
42
  forceHFBackend?: boolean;
43
  datasetOptions: SelectOption[];
44
  namespace?: string | null;
45
+ isEditing?: boolean;
46
+ onRequestOriginalView?: () => void;
47
  };
48
 
49
  const backendOptions = [
 
64
  forceHFBackend = false,
65
  datasetOptions,
66
  namespace,
67
+ isEditing = false,
68
+ onRequestOriginalView,
69
  }: SimplifiedJobProps) {
70
  const [showAdvanced, setShowAdvanced] = useState(false);
71
  const process = jobConfig.config.process[0];
 
97
 
98
  const dataset = process.datasets?.[0] ?? objectCopy(defaultDatasetConfig);
99
 
100
+ const [trainDatasetMode, setTrainDatasetMode] = useState<DatasetMode>('upload');
101
  const [trainModeTouched, setTrainModeTouched] = useState(hasCustomTrainPath);
102
  const [trainDatasetName, setTrainDatasetName] = useState(() =>
103
  slugify(jobConfig.config.name || 'training-data'),
 
112
  const [trainUploadInfo, setTrainUploadInfo] = useState<string | null>(null);
113
  const [trainUploadError, setTrainUploadError] = useState<string | null>(null);
114
 
115
+ const [controlDatasetMode, setControlDatasetMode] = useState<DatasetMode>('upload');
 
 
116
  const [controlModeTouched, setControlModeTouched] = useState(hasCustomControlPath);
117
  const [controlDatasetName, setControlDatasetName] = useState(() =>
118
  slugify(`${jobConfig.config.name || 'training'}-control`),
 
212
  const effectiveBackendOptions = forceHFBackend ? backendOptions.filter(opt => opt.value === 'hf-jobs') : backendOptions;
213
 
214
  useEffect(() => {
215
+ if (!trainModeTouched && isEditing && hasCustomTrainPath) {
216
+ setTrainDatasetMode('existing');
217
+ setTrainDatasetPath(process.datasets?.[0]?.folder_path ?? null);
 
 
218
  }
219
+ }, [hasCustomTrainPath, isEditing, process.datasets, trainModeTouched]);
220
 
221
  useEffect(() => {
222
+ if (!controlModeTouched && isEditing && hasCustomControlPath) {
223
+ setControlDatasetMode('existing');
224
+ setControlDatasetPath(
225
+ typeof process.datasets?.[0]?.control_path === 'string'
226
+ ? (process.datasets?.[0]?.control_path as string)
227
+ : null,
228
+ );
 
 
229
  }
230
+ }, [controlModeTouched, hasCustomControlPath, isEditing, process.datasets]);
231
 
232
  useEffect(() => {
233
  if (!trainDatasetNameTouched) {
 
523
  </Button>
524
  </div>
525
  {showAdvanced && (
526
+ <div className="mt-6 space-y-4">
527
+ <p className="text-xs text-gray-400">
528
+ If you want all AI Toolkit UI options,{' '}
529
+ {onRequestOriginalView ? (
530
+ <button
531
+ type="button"
532
+ className="text-blue-300 underline hover:text-blue-200"
533
+ onClick={onRequestOriginalView}
534
+ >
535
+ switch to the Original View
536
+ </button>
537
+ ) : (
538
+ <span className="text-blue-200">switch to the Original View</span>
539
+ )}
540
+ .
541
+ </p>
542
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
543
+ <SelectInput
544
+ label="Training Backend"
545
+ value={trainingBackend}
546
+ onChange={value => setTrainingBackend?.(value as 'local' | 'hf-jobs')}
547
+ options={effectiveBackendOptions}
548
  disabled={forceHFBackend || !setTrainingBackend}
549
  />
550
  {trainingBackend === 'local' && (
 
579
  { value: 'adafactor', label: 'Adafactor' },
580
  ]}
581
  />
582
+ <div className="flex items-center gap-2 pt-2">
583
+ <Checkbox
584
+ label="Skip First Sample"
585
+ checked={process.train.skip_first_sample}
586
+ onChange={value => setJobConfig(value, 'config.process[0].train.skip_first_sample')}
587
+ />
588
+ <Checkbox
589
+ label="Disable Sampling"
590
+ checked={process.train.disable_sampling}
591
+ onChange={value => setJobConfig(value, 'config.process[0].train.disable_sampling')}
592
+ />
593
+ </div>
594
  </div>
595
  </div>
596
  )}
 
601
  setTrainDatasetMode(value);
602
  setTrainModeTouched(true);
603
  })}
604
+ <p className="text-xs text-gray-400 mb-4">
605
+ {requiresControlDataset
606
+ ? 'Here upload the target images with their captions (e.g. cyclops1.png and cyclops1.txt with the caption "make him a cyclops").'
607
+ : 'Upload the images you want to train your model on. Add captions with the same name (e.g. photo1.jpg with photo1.txt).'}
608
+ </p>
609
 
610
  {trainDatasetMode === 'upload' ? (
611
  <div className="space-y-4">
 
684
  setControlDatasetMode(value);
685
  setControlModeTouched(true);
686
  })}
687
+ <p className="text-xs text-gray-400 mb-4">
688
+ Upload the source images using the same filenames as your targets (e.g. cyclops1.png for the original). Captions are not required in the control dataset.
689
+ </p>
690
 
691
  {controlDatasetMode === 'upload' ? (
692
  <div className="space-y-4">
ui/src/app/jobs/new/page.tsx CHANGED
@@ -250,7 +250,7 @@ export default function TrainingForm() {
250
  </div>
251
  </TopBar>
252
  {isAuthenticated && (
253
- <div className="bg-gray-900/70 border-b border-gray-700">
254
  <div className="flex justify-center gap-4 px-6 py-3">
255
  {(
256
  [
@@ -312,6 +312,8 @@ export default function TrainingForm() {
312
  forceHFBackend={usingBrowserDb}
313
  datasetOptions={datasetOptions}
314
  namespace={authNamespace}
 
 
315
  />
316
  </MainContent>
317
  ) : showAdvancedView ? (
 
250
  </div>
251
  </TopBar>
252
  {isAuthenticated && (
253
+ <div className="bg-gray-900/70 border-b border-gray-700 pt-16">
254
  <div className="flex justify-center gap-4 px-6 py-3">
255
  {(
256
  [
 
312
  forceHFBackend={usingBrowserDb}
313
  datasetOptions={datasetOptions}
314
  namespace={authNamespace}
315
+ isEditing={Boolean(runId)}
316
+ onRequestOriginalView={() => setActiveTab('original')}
317
  />
318
  </MainContent>
319
  ) : showAdvancedView ? (