mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
better detect input source
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Submodule extensions-builtin/sdnext-kanvas updated: dc7cfbface...a18c8a90a2
Submodule extensions-builtin/sdnext-modernui updated: 7d89b6efed...37b51427a9
@@ -4,14 +4,14 @@ function controlInputMode(inputMode, ...args) {
|
||||
const tab = gradioApp().querySelector('#control-tab-input button.selected');
|
||||
if (!tab) return ['Image', ...args];
|
||||
let inputTab = tab.innerText;
|
||||
log('controlInputMode', inputMode, inputTab);
|
||||
if ((inputTab === 'Image') && ('kanvas' in window)) {
|
||||
log('controlInputMode', { mode: inputMode, tab: inputTab, kanvas: typeof Kanvas });
|
||||
if ((inputTab === 'Image') && (typeof 'Kanvas' !== 'undefined')) {
|
||||
inputTab = 'Kanvas';
|
||||
// const imageData = window.kanvas.getImageData();
|
||||
const imageData = window.kanvas.getImage();
|
||||
args[0] = imageData;
|
||||
}
|
||||
return [inputMode, ...args];
|
||||
return [inputTab, ...args];
|
||||
}
|
||||
|
||||
async function setupControlUI() {
|
||||
|
||||
@@ -521,7 +521,7 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg
|
||||
yield terminate('Interrupted')
|
||||
return [], '', '', 'Interrupted'
|
||||
# get input
|
||||
if isinstance(input_image, str):
|
||||
if isinstance(input_image, str) and os.path.exists(input_image):
|
||||
try:
|
||||
input_image = Image.open(input_image)
|
||||
except Exception as e:
|
||||
|
||||
@@ -67,6 +67,8 @@ def display_units(num_units):
|
||||
|
||||
|
||||
def get_video(filepath: str):
|
||||
if not os.path.exists(filepath):
|
||||
return ''
|
||||
try:
|
||||
frames, fps, duration, w, h, codec, _cap = video.get_video_params(filepath)
|
||||
shared.log.debug(f'Control: input video: path={filepath} frames={frames} fps={fps} size={w}x{h} codec={codec}')
|
||||
@@ -175,7 +177,7 @@ def select_input(input_mode, input_image, init_image, init_type, input_video, in
|
||||
input_source = [selected_input.value]
|
||||
input_type = 'gr.Image'
|
||||
res = [gr.Tabs.update(selected='out-gallery'), input_mask, status]
|
||||
elif isinstance(selected_input, str): # video via upload > tmp filepath to video
|
||||
elif isinstance(selected_input, str) and os.path.exists(selected_input): # video via upload > tmp filepath to video
|
||||
input_source = selected_input
|
||||
input_type = 'gr.Video'
|
||||
status = get_video(input_source)
|
||||
|
||||
Reference in New Issue
Block a user