def from_files(job, form):
 if form.textfile_use_local_files.data:
  job.labels_file = form.textfile_local_labels_file.data.strip()
 else:
  flask.request.files[form.textfile_labels_file.name].save(os.path.join(job.dir(), utils.constants.LABELS_FILE))
  job.labels_file = utils.constants.LABELS_FILE
 shuffle = bool(form.textfile_shuffle.data)
 backend = form.backend.data
 encoding = form.encoding.data
 compression = form.compression.data
 if form.textfile_use_local_files.data:
  train_file = form.textfile_local_train_images.data.strip()
 else:
  flask.request.files[form.textfile_train_images.name].save(os.path.join(job.dir(), utils.constants.TRAIN_FILE))
  train_file = utils.constants.TRAIN_FILE
 image_folder = form.textfile_train_folder.data.strip()
 if (not image_folder):
  image_folder = None
 job.tasks.append(tasks.CreateDbTask(job_dir=job.dir(), input_file=train_file, db_name=utils.constants.TRAIN_DB, backend=backend, image_dims=job.image_dims, image_folder=image_folder, resize_mode=job.resize_mode, encoding=encoding, compression=compression, mean_file=utils.constants.MEAN_FILE_CAFFE, labels_file=job.labels_file, shuffle=shuffle))
 if form.textfile_use_val.data:
  if form.textfile_use_local_files.data:
   val_file = form.textfile_local_val_images.data.strip()
  else:
   flask.request.files[form.textfile_val_images.name].save(os.path.join(job.dir(), utils.constants.VAL_FILE))
   val_file = utils.constants.VAL_FILE
  image_folder = form.textfile_val_folder.data.strip()
  if (not image_folder):
   image_folder = None
  job.tasks.append(tasks.CreateDbTask(job_dir=job.dir(), input_file=val_file, db_name=utils.constants.VAL_DB, backend=backend, image_dims=job.image_dims, image_folder=image_folder, resize_mode=job.resize_mode, encoding=encoding, compression=compression, labels_file=job.labels_file, shuffle=shuffle))
 if form.textfile_use_test.data:
  if form.textfile_use_local_files.data:
   test_file = form.textfile_local_test_images.data.strip()
  else:
   flask.request.files[form.textfile_test_images.name].save(os.path.join(job.dir(), utils.constants.TEST_FILE))
   test_file = utils.constants.TEST_FILE
  image_folder = form.textfile_test_folder.data.strip()
  if (not image_folder):
   image_folder = None
  job.tasks.append(tasks.CreateDbTask(job_dir=job.dir(), input_file=test_file, db_name=utils.constants.TEST_DB, backend=backend, image_dims=job.image_dims, image_folder=image_folder, resize_mode=job.resize_mode, encoding=encoding, compression=compression, labels_file=job.labels_file, shuffle=shuffle))

def from_files ( job , form ) : if form . textfile_use_local_files . data : job . labels_file = form . textfile_local_labels_file . data . strip ( ) else : flask . request . files [ form . textfile_labels_file . name ] . save ( os . path . join ( job . dir ( ) , utils . constants . LABELS_FILE ) ) job . labels_file = utils . constants . LABELS_FILE shuffle = bool ( form . textfile_shuffle . data ) backend = form . backend . data encoding = form . encoding . data compression = form . compression . data if form . textfile_use_local_files . data : train_file = form . textfile_local_train_images . data . strip ( ) else : flask . request . files [ form . textfile_train_images . name ] . save ( os . path . join ( job . dir ( ) , utils . constants . TRAIN_FILE ) ) train_file = utils . constants . TRAIN_FILE image_folder = form . textfile_train_folder . data . strip ( ) if ( not image_folder ) : image_folder = None job . tasks . append ( tasks . CreateDbTask ( job_dir = job . dir ( ) , input_file = train_file , db_name = utils . constants . TRAIN_DB , backend = backend , image_dims = job . image_dims , image_folder = image_folder , resize_mode = job . resize_mode , encoding = encoding , compression = compression , mean_file = utils . constants . MEAN_FILE_CAFFE , labels_file = job . labels_file , shuffle = shuffle ) ) if form . textfile_use_val . data : if form . textfile_use_local_files . data : val_file = form . textfile_local_val_images . data . strip ( ) else : flask . request . files [ form . textfile_val_images . name ] . save ( os . path . join ( job . dir ( ) , utils . constants . VAL_FILE ) ) val_file = utils . constants . VAL_FILE image_folder = form . textfile_val_folder . data . strip ( ) if ( not image_folder ) : image_folder = None job . tasks . append ( tasks . CreateDbTask ( job_dir = job . dir ( ) , input_file = val_file , db_name = utils . constants . VAL_DB , backend = backend , image_dims = job . image_dims , image_folder = image_folder , resize_mode = job . resize_mode , encoding = encoding , compression = compression , labels_file = job . labels_file , shuffle = shuffle ) ) if form . textfile_use_test . data : if form . textfile_use_local_files . data : test_file = form . textfile_local_test_images . data . strip ( ) else : flask . request . files [ form . textfile_test_images . name ] . save ( os . path . join ( job . dir ( ) , utils . constants . TEST_FILE ) ) test_file = utils . constants . TEST_FILE image_folder = form . textfile_test_folder . data . strip ( ) if ( not image_folder ) : image_folder = None job . tasks . append ( tasks . CreateDbTask ( job_dir = job . dir ( ) , input_file = test_file , db_name = utils . constants . TEST_DB , backend = backend , image_dims = job . image_dims , image_folder = image_folder , resize_mode = job . resize_mode , encoding = encoding , compression = compression , labels_file = job . labels_file , shuffle = shuffle ) )
generate a table of contents from files in the book .