File size: 3,178 Bytes
f7a6c5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b34109c
 
 
 
f7a6c5f
 
 
 
 
 
 
 
 
 
 
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import csv
import requests
from io import StringIO
from typing import Union, Optional, Tuple
from PIL import Image
import random

__version__ = "0.0.1_GenAI_Arena"

DOMAIN = "https://chromaica.github.io/Museum/"

TASK_DICT = {
    "t2i": "ImagenHub_Text-Guided_IG",
    "tie": "ImagenHub_Text-Guided_IE",
    "mie": "ImagenHub_Control-Guided_IG",
    "cig": "ImagenHub_Control-Guided_IE",
    "msdig": "ImagenHub_Multi-Concept_IC",
    "sdig": "ImagenHub_Subject-Driven_IG",
    "sdie": "ImagenHub_Subject-Driven_IE"
}

t2i_models= [
      "SD",
      "SDXL",
      "OpenJourney",
      "DeepFloydIF",
      "DALLE2"
    ]

mie_models =  [
      "Glide",
      "SDInpaint",
      "BlendedDiffusion",
      "SDXLInpaint"
    ] 

tie_models = [
      "DiffEdit",
      "MagicBrush",
      "InstructPix2Pix",
      "Prompt2prompt",
      "Text2Live",
      "SDEdit",
      "CycleDiffusion",
      "Pix2PixZero"
    ]

sdig_models = [
      "DreamBooth",
      "DreamBoothLora",
      "TextualInversion",
      "BLIPDiffusion_Gen"
    ]

sdie_models = [
      "PhotoSwap",
      "DreamEdit",
      "BLIPDiffusion_Edit"
    ] 

msdig_models = [
      "DreamBooth",
      "CustomDiffusion",
      "TextualInversion"
    ]

cig_models = [
      "ControlNet",
      "UniControl"
    ]

def fetch_csv_keys(url):
    """
    Fetches a CSV file from a given URL and parses it into a list of keys,
    ignoring the header line.
    """
    response = requests.get(url)
    response.raise_for_status()  # Ensure we notice bad responses
    
    # Use StringIO to turn the fetched text data into a file-like object
    csv_file = StringIO(response.text)

    # Create a CSV reader
    csv_reader = csv.reader(csv_file)

    # Skip the header
    next(csv_reader, None)

    # Return the list of keys
    return [row[0] for row in csv_reader if row]

def fetch_json_data(url):
    """
    Fetches JSON data from a given URL.
    """
    response = requests.get(url)
    response.raise_for_status()
    return response.json()

def fetch_data_and_match(csv_url, json_url):
    """
    Fetches a list of keys from a CSV and then fetches JSON data and matches the keys to the JSON.
    """
    # Fetch keys from CSV
    keys = fetch_csv_keys(csv_url)
    
    # Fetch JSON data
    json_data = fetch_json_data(json_url)
    
    # Extract relevant data using keys
    matched_data = {key: json_data.get(key) for key in keys if key in json_data}

    return matched_data

def fetch_indexes(baselink):
    matched_results = fetch_data_and_match(baselink+"/dataset_lookup.csv", baselink+"/dataset_lookup.json")
    return matched_results

def fetch_indexes_no_csv(baselink):
    matched_results = fetch_json_data(baselink+"/dataset_lookup.json")
    return matched_results

if __name__ == "__main__":
    domain = "https://chromaica.github.io/Museum/"
    baselink = domain + "ImagenHub_Text-Guided_IE"
    matched_results = fetch_indexes(baselink)
    for uid, value in matched_results.items():
        print(uid)
        model = "CycleDiffusion"
        image_link = baselink + "/" + model + "/" + uid
        print(image_link)
        instruction = value['instruction']
        print(instruction)