revert to stable (might be hub issues)
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ import time
|
|
9 |
import re
|
10 |
from discord import Embed, Color
|
11 |
from discord.ext import commands
|
12 |
-
# restart #unstick
|
13 |
from gradio_client import Client
|
14 |
from PIL import Image
|
15 |
#from ratelimiter import RateLimiter
|
@@ -18,7 +18,6 @@ from datetime import datetime
|
|
18 |
from pytz import timezone
|
19 |
#
|
20 |
import asyncio
|
21 |
-
semaphore = asyncio.Semaphore(1) # for concurrent tasks
|
22 |
|
23 |
zurich_tz = timezone("Europe/Zurich")
|
24 |
|
@@ -36,32 +35,30 @@ intents.message_content = True
|
|
36 |
bot = commands.Bot(command_prefix='!', intents=intents)
|
37 |
|
38 |
|
39 |
-
|
|
|
40 |
@bot.event
|
41 |
async def on_ready():
|
42 |
print('Logged on as', bot.user)
|
43 |
bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
|
44 |
|
45 |
-
|
46 |
# Stage 1
|
47 |
@bot.command()
|
48 |
async def deepfloydif(ctx, *, prompt: str):
|
49 |
try:
|
50 |
-
await ctx.message.add_reaction('👍')
|
51 |
-
|
52 |
prompt = prompt.strip()[:100] # Limit the prompt length to 100 characters
|
53 |
prompt = re.sub(r'[^\w\s]', '', prompt) # Remove special characters
|
54 |
|
55 |
def check_reaction(reaction, user):
|
56 |
return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
|
57 |
|
|
|
58 |
number_of_images = 4
|
59 |
current_time = int(time.time())
|
60 |
random.seed(current_time)
|
61 |
seed = random.randint(0, 2**32 - 1)
|
62 |
-
stage_1_results, stage_1_param_path, stage_1_result_path = df.predict
|
63 |
-
(prompt, "blur", seed, number_of_images, 7.0, 'smart100', 50, api_name="/generate64")
|
64 |
-
|
65 |
png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
|
66 |
|
67 |
if png_files:
|
@@ -145,10 +142,8 @@ async def dfif2(ctx, index: int, stage_1_result_path):
|
|
145 |
print(f"Error: {e}")
|
146 |
await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
|
147 |
#----------------------------------------------------------------------------------------------------------------------------
|
148 |
-
|
149 |
-
|
150 |
-
await dfif2(ctx, index, stage_1_result_path)
|
151 |
-
#----------------------------------------------------------------------------------------------------------------------------
|
152 |
|
153 |
|
154 |
|
|
|
9 |
import re
|
10 |
from discord import Embed, Color
|
11 |
from discord.ext import commands
|
12 |
+
# restart #unstick
|
13 |
from gradio_client import Client
|
14 |
from PIL import Image
|
15 |
#from ratelimiter import RateLimiter
|
|
|
18 |
from pytz import timezone
|
19 |
#
|
20 |
import asyncio
|
|
|
21 |
|
22 |
zurich_tz = timezone("Europe/Zurich")
|
23 |
|
|
|
35 |
bot = commands.Bot(command_prefix='!', intents=intents)
|
36 |
|
37 |
|
38 |
+
#----------------------------------------------------------------------------------------------------------------------------------------------
|
39 |
+
|
40 |
@bot.event
|
41 |
async def on_ready():
|
42 |
print('Logged on as', bot.user)
|
43 |
bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
|
44 |
|
45 |
+
#----------------------------------------------------------------------------------------------------------------------------------------------
|
46 |
# Stage 1
|
47 |
@bot.command()
|
48 |
async def deepfloydif(ctx, *, prompt: str):
|
49 |
try:
|
|
|
|
|
50 |
prompt = prompt.strip()[:100] # Limit the prompt length to 100 characters
|
51 |
prompt = re.sub(r'[^\w\s]', '', prompt) # Remove special characters
|
52 |
|
53 |
def check_reaction(reaction, user):
|
54 |
return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
|
55 |
|
56 |
+
|
57 |
number_of_images = 4
|
58 |
current_time = int(time.time())
|
59 |
random.seed(current_time)
|
60 |
seed = random.randint(0, 2**32 - 1)
|
61 |
+
stage_1_results, stage_1_param_path, stage_1_result_path = df.predict(prompt, "blur", seed, number_of_images, 7.0, 'smart100', 50, api_name="/generate64")
|
|
|
|
|
62 |
png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
|
63 |
|
64 |
if png_files:
|
|
|
142 |
print(f"Error: {e}")
|
143 |
await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
|
144 |
#----------------------------------------------------------------------------------------------------------------------------
|
145 |
+
|
146 |
+
|
|
|
|
|
147 |
|
148 |
|
149 |
|