import os, sys, random, string, time, logging from threading import Thread from pathlib import Path from queue import Queue import gradio as App logging.basicConfig(level=logging.INFO, format=f'[%(asctime)s] %(message)s', datefmt='%H:%M:%S') logging.info('Starting Dreamlike Grouped') logging.info('Loading MagicPrompt') MagicPrompt=App.Interface.load('spaces/phenomenon1981/MagicPrompt-Stable-Diffusion') def get_prompts(prompt_text): if prompt_text: return MagicPrompt('dreamlikeart, ' + prompt_text) else: return MagicPrompt('') logging.info('loading Dreamlike Diffusion') DreamDiffusion=App.Interface.load('models/SG161222/Realistic_Vision_V1.4') # Credits to SG161222 logging.info('Loading Dreamlike PhotoReal') DreamPhotoReal = DreamDiffusion DreamPhotoReal=App.Interface.load('models/dreamlike-art/dreamlike-photoreal-2.0') # Credits to Dreamlike def RestartScript(): while True: RandomTime = random.randint(540, 600) time.sleep(RandomTime) os.execl(sys.executable, sys.executable, *sys.argv) logging.info('Starting Auto-Restarter') RestartThread = Thread(target=RestartScript, daemon=True) RestartThread.start() queue = Queue() queue_threshold = 100 def AddNoise(Prompt, neg_prompt, NoiseLevel=0.00): if NoiseLevel == 0: NoiseLevel = 0.00 PercentageNoise = NoiseLevel * 5 NumberNoiseCharacters = int(len(Prompt) * (PercentageNoise/100)) NoiseIndices = random.sample(range(len(Prompt)), NumberNoiseCharacters) PromptList = list(Prompt) NoiseCharacters = list(string.ascii_letters + string.punctuation + ' ' + string.digits) NoiseCharacters.extend(['ð', 'ðĐ', 'ð', 'ðĪ', 'ð', 'ðĪ', 'ð', 'ð', 'ð·', 'ðĪŊ', 'ðĪŦ', 'ðĨī', 'ðī', 'ðĪĐ', 'ðĨģ', 'ð', 'ðĐ', 'ðĪŠ', 'ð', 'ðĪĒ', 'ð', 'ðđ', 'ðŧ', 'ðĪ', 'ð―', 'ð', 'ð', 'ð ', 'ð', 'ð', 'ð', 'ð', 'ð', 'ð', 'ðŪ', 'âĪïļ', 'ð', 'ð', 'ð', 'ð', 'ðķ', 'ðą', 'ð', 'ðđ', 'ðĶ', 'ðŧ', 'ðĻ', 'ðŊ', 'ðĶ', 'ð', 'ðĨ', 'ð§ïļ', 'ð', 'ð', 'ðĨ', 'ðī', 'ð', 'ðš', 'ðŧ', 'ðļ', 'ðĻ', 'ð ', 'ð', 'âïļ', 'âïļ', 'âïļ', 'âïļ', 'ðĪïļ', 'â ïļ', 'ðĨïļ', 'ðĶïļ', 'ð§ïļ', 'ðĐïļ', 'ðĻïļ', 'ðŦïļ', 'âïļ', 'ðŽïļ', 'ðĻ', 'ðŠïļ', 'ð']) for Index in NoiseIndices: PromptList[Index] = random.choice(NoiseCharacters) return ''.join(PromptList) def GetRandomPrompt(): with open('Prompts.txt', 'r') as Prompts: Prompts = Prompts.readlines() return random.choice(Prompts) def SendIt1(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On 8 Threads') logging.info(f'Using Prompt: {Inputs}') logging.info('Creating Image On Thread 1') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output1 = DreamDiffusion(NoisedPrompt) logging.info('Done Creating Image On Thread 1') return Output1 def SendIt2(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On Thread 2') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output2 = DreamDiffusion(NoisedPrompt) logging.info('Done Creating Image On Thread 2') return Output2 def SendIt3(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On Thread 3') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output3 = DreamDiffusion(NoisedPrompt) logging.info('Done Creating Image On Thread 3') return Output3 def SendIt4(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On Thread 4') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output4 = DreamDiffusion(NoisedPrompt) logging.info('Done Creating Image On Thread 4') return Output4 def SendIt5(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On Thread 5') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output5 = DreamPhotoReal(NoisedPrompt) logging.info('Done Creating Image On Thread 5') return Output5 def SendIt6(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On Thread 6') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output6 = DreamPhotoReal(NoisedPrompt) logging.info('Done Creating Image On Thread 6') return Output6 def SendIt7(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On Thread 7') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output7 = DreamPhotoReal(NoisedPrompt) logging.info('Done Creating Image On Thread 7') return Output7 def SendIt8(Inputs, NoiseLevel, DreamDiffusion=DreamDiffusion): logging.info('Creating Image On Thread 8') NoisedPrompt = AddNoise(Inputs, NoiseLevel) while queue.qsize() >= queue_threshold: time.sleep(2) queue.put(NoisedPrompt) Output8 = DreamPhotoReal(NoisedPrompt) logging.info('Done Creating Image On Thread 8') return Output8 logging.info('Loading Interface') with App.Blocks(css='style.css') as demo: App.HTML( '''
Dreamlike Diffusion 1.4 | Dreamlike PhotoReal 2.0 Noise Level: Controls how much randomness is added to the input before it is sent to the model. Higher noise level produces more diverse Outputs, while lower noise level produces similar Outputs, .
âĪïļ Press the Like Button if you enjoy my space! âĪïļ
Unleash your creative side and generate mesmerizing images with just a few clicks! Enter a spark of inspiration in the 'Basic Idea' text box and click the 'Magic Prompt' button to elevate it to a polished masterpiece. Make any final tweaks in the 'Full Prompt' box and hit the 'Generate Images' button to watch your vision come to life. Experiment with the 'Noise Level' for a diverse range of Outputs, from similar to wildly unique. Let the fun begin!