File size: 982 Bytes
5e15a30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

def read_file_to_dic(file_path):
    dic = {}
    with open(file_path, 'r') as file:
        for line in file:
            # Skip comments and empty lines
            if line.strip() and not line.startswith('//'):
                key, value = line.strip().split('=', 1)
                values = value.split(';')
                dic[key] = values
    return dic

def get_examples_dataset(values):
    return gr.Dataset(samples=get_examples_arr(values))

def get_examples_arr(values):
    samples = []
    for value in values:
        samples.append([value])
    
    return samples

def get_images(imagePaths):
    images = []
    for imagePath in imagePaths:
        try:
            images.append(gr.Image(imagePath))
        except gr.exceptions.InvalidPathError:
            print(f"Image not found: {imagePath}")  

    return images

#test = read_file_to_dic('hints_config.txt')
#images = get_examples_arr(test["1"])
#for image in images:
#    print(image)