File size: 3,140 Bytes
486a808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import gradio as gr
import GPUtil

DIFFUSION_CHECKPOINTS = {
    "General (SD 2.1)": {
        "path": "stabilityai/stable-diffusion-2-1",
        "type": "pretrained",
        "pipeline": "StableDiffusionPipeline"
    },
    "Realistic (SD 1.5)": {
        "path": "/root/tungn197/genAI/checkpoints/realisticVisionV60B1_v51HyperVAE.safetensors",
        "type": "file",
        "pipeline": "StableDiffusionPipeline"
    },
    "Anime (SD 1.5)": {
        "path": "/root/tungn197/genAI/checkpoints/darkSushiMixMix_225D.safetensors",
        "type": "file",
        "pipeline": "StableDiffusionPipeline"
    },
    "Comic Book (SD 1.5)": {
        "path": "/media/drive-2t/tungn197/checkpoints/realisticComicBook_v10.safetensors",
        "type": "file",
        "pipeline": "StableDiffusionPipeline"
    },
    "MajicMixRealisticV7 (SD 1.5 Focus on Asian face)": {
        "path": "/root/tungn197/genAI/checkpoints/majicmixRealistic_v7.safetensors",
        "type": "file",
        "pipeline": "StableDiffusionPipeline"
    },
    "AniMeshFullV22 (SD 1.5)": {
        "path": "/media/drive-2t/tungn197/checkpoints/animesh_FullV22.safetensors",
        "type": "file",
        "pipeline": "StableDiffusionPipeline"
    },
    "epiCRealism XL (SDXL 1.0)": {
        "path": "/root/tungn197/genAI/checkpoints/epicrealismXL_v7FinalDestination.safetensors",
        "type": "file",
        "pipeline": "StableDiffusionXLPipeline"
    },
    "Juggernaut X Hyper (SDXL 1.0)": {
        "path": "RunDiffusion/Juggernaut-X-Hyper",
        "type": "pretrained",
        "pipeline": "StableDiffusionXLPipeline"
    }
}
AUTH_USER = [("admin", "admin")]
DEVICE = "cuda:0"
APP_THEME = gr.Theme.from_hub("ParityError/Interstellar")

def read_md_file_to_string(file_path):
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            file_content = file.read()
        return file_content
    except FileNotFoundError:
        print(f"The file at {file_path} was not found.")
    except Exception as e:
        print(f"An error occurred: {e}")

def nearest_divisible_by_8(n):
    lower_multiple = (n // 8) * 8
    upper_multiple = lower_multiple + 8
    if (n - lower_multiple) < (upper_multiple - n):
        return int(lower_multiple)
    else:
        return int(upper_multiple)

def get_gpu_info():
    gpus = GPUtil.getGPUs()
    gpu_info = []
    for gpu in gpus:
        info = {
            'id': gpu.id,
            'name': gpu.name,
            'driver_version': gpu.driver,
            'total_memory': gpu.memoryTotal,  # In MB
            'available_memory': gpu.memoryFree,  # In MB
            'used_memory': gpu.memoryUsed,  # In MB
            'temperature': gpu.temperature  # In Celsius
        }
        gpu_info.append(info)
    return gpu_info

def display_gpu_info():
    info_list = []
    gpus = get_gpu_info()
    for info in gpus:
        info_list.append(f"GPU {info['id']} ({info['name']}, Total: {info['total_memory']} MB, Available: {info['available_memory']} MB)")
    return info_list

GPUS = get_gpu_info()
DISPLAYED_GPUS_INFO = []
for info in GPUS:
    DISPLAYED_GPUS_INFO.append(f"GPU {info['id']}")