Spaces:
Build error
Build error
Download utils.py from OrangeLabs/v2: direct link, hf CLI and curl.
- Browser
- Download file 982 Bytes
-
https://huggingface.co/spaces/OrangeLabs/v2/resolve/main/utils.py
- Command line
-
hf download hf://spaces/OrangeLabs/v2/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/OrangeLabs/v2/resolve/main/utils.py
982 Bytes
| 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) |