lunarflu HF Staff commited on
Commit
b6ca34b
Β·
1 Parent(s): 6fa20df
Files changed (1) hide show
  1. app.py +47 -13
app.py CHANGED
@@ -4,7 +4,7 @@ from gradio_client import Client
4
  import gradio as gr
5
  import os
6
  import threading
7
- ......
8
  #for deepfloydif
9
  import requests
10
  import json
@@ -22,17 +22,10 @@ import matplotlib.image as mpimg
22
  # Get Gradio client
23
  jojogan = gradio_client.Client("akhaliq/JoJoGAN")
24
 
25
- #new
26
- '''
27
- deepfloydif = gradio_client.Client("DeepFloyd/IF")
28
- client = Client("DeepFloyd/IF")
29
- client.view_api()
30
-
31
- '''
32
-
33
-
34
- df = Client("DeepFloyd/IF")
35
 
 
 
 
36
 
37
 
38
  # Set up discord bot
@@ -40,8 +33,15 @@ class MyClient(discord.Client):
40
  async def on_ready(self):
41
  print('Logged on as', self.user)
42
 
 
43
  async def on_message(self, message):
44
 
 
 
 
 
 
 
45
  # if the bot has this role, it won't run
46
  OFFLINE_ROLE_ID = 1103676632667017266 # 1103676632667017266 = @offline-bot
47
  guild = message.guild
@@ -63,6 +63,9 @@ class MyClient(discord.Client):
63
  if message.channel.id not in ALLOWED_CHANNEL_IDS:
64
  return
65
 
 
 
 
66
  if message.content.find("!help") != -1:
67
  await message.reply("Use !jojo !disney !spidey or !sketch. Have fun!", mention_author=True)
68
 
@@ -90,7 +93,7 @@ class MyClient(discord.Client):
90
  else:
91
  await message.channel.send("No attachments to be found...Can't animify dat! Try sending me an image πŸ˜‰")
92
 
93
- #new
94
  #deepfloydif
95
  '''
96
  if message.content.startswith('!deepfloydif'):
@@ -108,6 +111,30 @@ class MyClient(discord.Client):
108
  #deepfloydif
109
  # start with preset values for now
110
  if message.content.startswith('!deepfloydif'):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  # stage 1
112
  prompt = "llama"
113
  negative_prompt = "blue"
@@ -134,7 +161,14 @@ class MyClient(discord.Client):
134
 
135
  # Send the image file as a Discord attachment
136
  with open(img_path, 'rb') as f:
137
- await message.reply(f'Here is the generated image', file=discord.File(f, 'generated_image.png'))
 
 
 
 
 
 
 
138
 
139
 
140
  DISCORD_TOKEN = os.environ.get("GRADIOTEST_TOKEN", None)
 
4
  import gradio as gr
5
  import os
6
  import threading
7
+
8
  #for deepfloydif
9
  import requests
10
  import json
 
22
  # Get Gradio client
23
  jojogan = gradio_client.Client("akhaliq/JoJoGAN")
24
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ #deepfloydif
27
+ #df = Client("DeepFloyd/IF") #not reliable at the moment
28
+ df = Client("huggingface-projects/IF", hf_token=DFIF_TOKEN)
29
 
30
 
31
  # Set up discord bot
 
33
  async def on_ready(self):
34
  print('Logged on as', self.user)
35
 
36
+ #----------------------------------------------------------------------------------------------------
37
  async def on_message(self, message):
38
 
39
+ #tldr, bot should run if
40
+ #1) it does not have @offline role
41
+ #2) user has @verified role
42
+ #3) bot is in #bot-test channel
43
+
44
+
45
  # if the bot has this role, it won't run
46
  OFFLINE_ROLE_ID = 1103676632667017266 # 1103676632667017266 = @offline-bot
47
  guild = message.guild
 
63
  if message.channel.id not in ALLOWED_CHANNEL_IDS:
64
  return
65
 
66
+ #----------------------------------------------------------------------------------------------------
67
+ #jojogan
68
+
69
  if message.content.find("!help") != -1:
70
  await message.reply("Use !jojo !disney !spidey or !sketch. Have fun!", mention_author=True)
71
 
 
93
  else:
94
  await message.channel.send("No attachments to be found...Can't animify dat! Try sending me an image πŸ˜‰")
95
 
96
+ #----------------------------------------------------------------------------------------------------
97
  #deepfloydif
98
  '''
99
  if message.content.startswith('!deepfloydif'):
 
111
  #deepfloydif
112
  # start with preset values for now
113
  if message.content.startswith('!deepfloydif'):
114
+
115
+ #predict
116
+ stage_1_results, stage_1_param_path, stage_1_result_path = df.predict("gradio written on a wall", "blur", 1,4,7.0, 'smart100',50, api_name="/generate64")
117
+
118
+ # Assuming stage_1_results contains the path to the directory
119
+ png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
120
+
121
+ # Assuming png_files contains the list of all PNG files in the directory
122
+ if png_files:
123
+ first_png = png_files[0]
124
+ first_png_path = os.path.join(stage_1_results, first_png)
125
+
126
+ # Send the image file as a Discord attachment
127
+ with open(first_png_path, 'rb') as f:
128
+ await message.reply(f'Here is the first generated image', file=discord.File(f, 'first_png.png'))
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ '''
138
  # stage 1
139
  prompt = "llama"
140
  negative_prompt = "blue"
 
161
 
162
  # Send the image file as a Discord attachment
163
  with open(img_path, 'rb') as f:
164
+ await message.reply(f'Here is the generated image', file=discord.File(f, 'generated_image.png'))
165
+
166
+
167
+
168
+
169
+
170
+ '''
171
+
172
 
173
 
174
  DISCORD_TOKEN = os.environ.get("GRADIOTEST_TOKEN", None)