File size: 844 Bytes
0db648b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python

from __future__ import annotations

import gradio as gr


def read_info(file_name: str) -> str:
    with open(file_name) as f:
        content = f.read()
    return content


def load_model(model_name: str) -> gr.Interface:
    iface = gr.Interface.load(model_name, src='models')
    for component in iface.output_components:
        component.label = f'{component.label} ({model_name})'
    return iface


def load_models(model_names: list[str]) -> list[gr.Interface]:
    return [load_model(name) for name in model_names]


title = read_info('TITLE')
description = read_info('DESCRIPTION')
article = read_info('ARTICLE')
model_names = read_info('MODEL_NAMES').split('\n')

interfaces = load_models(model_names)
gr.Parallel(
    *interfaces,
    title=title,
    description=description,
    article=article,
).launch()