Commit 6d805b66 authored by AUTOMATIC's avatar AUTOMATIC
Browse files

make CLIP interrogator download original text files if the directory does not exist

remove random artist built-in extension (to re-added as a normal extension on demand)
remove artists.csv (but what does it mean????????????????????)
make interrogate buttons show Loading... when you click them
parent 40ff6db5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ A browser interface based on Gradio library for Stable Diffusion.
- Running arbitrary python code from UI (must run with --allow-code to enable)
- Mouseover hints for most UI elements
- Possible to change defaults/mix/max/step values for UI elements via text config
- Random artist button
- Tiling support, a checkbox to create images that can be tiled like textures
- Progress bar and live image generation preview
- Negative prompt, an extra text field that allows you to list what you don't want to see in generated image

artists.csv

deleted100644 → 0
+0 −3041

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −50
Original line number Diff line number Diff line
import random

from modules import script_callbacks, shared
import gradio as gr

art_symbol = '\U0001f3a8'  # 🎨
global_prompt = None
related_ids = {"txt2img_prompt", "txt2img_clear_prompt", "img2img_prompt", "img2img_clear_prompt" }


def roll_artist(prompt):
    allowed_cats = set([x for x in shared.artist_db.categories() if len(shared.opts.random_artist_categories)==0 or x in shared.opts.random_artist_categories])
    artist = random.choice([x for x in shared.artist_db.artists if x.category in allowed_cats])

    return prompt + ", " + artist.name if prompt != '' else artist.name


def add_roll_button(prompt):
    roll = gr.Button(value=art_symbol, elem_id="roll", visible=len(shared.artist_db.artists) > 0)

    roll.click(
        fn=roll_artist,
        _js="update_txt2img_tokens",
        inputs=[
            prompt,
        ],
        outputs=[
            prompt,
        ]
    )


def after_component(component, **kwargs):
    global global_prompt

    elem_id = kwargs.get('elem_id', None)
    if elem_id not in related_ids:
        return

    if elem_id == "txt2img_prompt":
        global_prompt = component
    elif elem_id == "txt2img_clear_prompt":
        add_roll_button(global_prompt)
    elif elem_id == "img2img_prompt":
        global_prompt = component
    elif elem_id == "img2img_clear_prompt":
        add_roll_button(global_prompt)


script_callbacks.on_after_component(after_component)
+0 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ titles = {
    "Seed": "A value that determines the output of random number generator - if you create an image with same parameters and seed as another image, you'll get the same result",
    "\u{1f3b2}\ufe0f": "Set seed to -1, which will cause a new random number to be used every time",
    "\u267b\ufe0f": "Reuse seed from last generation, mostly useful if it was randomed",
    "\u{1f3a8}": "Add a random artist to the prompt.",
    "\u2199\ufe0f": "Read generation parameters from prompt or last generation if prompt is empty into user interface.",
    "\u{1f4c2}": "Open images output directory",
    "\u{1f4be}": "Save style",
+0 −8
Original line number Diff line number Diff line
@@ -126,8 +126,6 @@ class Api:
        self.add_api_route("/sdapi/v1/face-restorers", self.get_face_restorers, methods=["GET"], response_model=List[FaceRestorerItem])
        self.add_api_route("/sdapi/v1/realesrgan-models", self.get_realesrgan_models, methods=["GET"], response_model=List[RealesrganItem])
        self.add_api_route("/sdapi/v1/prompt-styles", self.get_prompt_styles, methods=["GET"], response_model=List[PromptStyleItem])
        self.add_api_route("/sdapi/v1/artist-categories", self.get_artists_categories, methods=["GET"], response_model=List[str])
        self.add_api_route("/sdapi/v1/artists", self.get_artists, methods=["GET"], response_model=List[ArtistItem])
        self.add_api_route("/sdapi/v1/embeddings", self.get_embeddings, methods=["GET"], response_model=EmbeddingsResponse)
        self.add_api_route("/sdapi/v1/refresh-checkpoints", self.refresh_checkpoints, methods=["POST"])
        self.add_api_route("/sdapi/v1/create/embedding", self.create_embedding, methods=["POST"], response_model=CreateResponse)
@@ -390,12 +388,6 @@ class Api:

        return styleList

    def get_artists_categories(self):
        return shared.artist_db.cats

    def get_artists(self):
        return [{"name":x[0], "score":x[1], "category":x[2]} for x in shared.artist_db.artists]

    def get_embeddings(self):
        db = sd_hijack.model_hijack.embedding_db

Loading