skkk commited on
Commit
37679c0
1 Parent(s): 599e14e

change some example and warning

Browse files
Files changed (2) hide show
  1. Rodin.py +9 -4
  2. app.py +0 -3
Rodin.py CHANGED
@@ -5,6 +5,7 @@ import time
5
  import random
6
  import base64
7
  import io
 
8
  from PIL import Image
9
  from io import BytesIO
10
  import gradio as gr
@@ -55,7 +56,7 @@ def rodin_preprocess_image(generate_prompt, image, name, token):
55
 
56
  def crop_image(image, type):
57
  if image == None:
58
- raise gr.Error("Generate Model First")
59
  new_image_width = 360 * (11520 // 720) # 每隔720像素裁切一次,每次裁切宽度为360
60
  new_image_height = 360 # 新图片的高度
61
  new_image = Image.new('RGB', (new_image_width, new_image_height))
@@ -107,7 +108,10 @@ def rodin_update(prompt, task_uuid, token, settings):
107
  return response.json()
108
 
109
  def load_image(img_path):
110
- image = Image.open(img_path)
 
 
 
111
 
112
  # 按比例缩小图像到长度为1024
113
  width, height = image.size
@@ -204,12 +208,13 @@ class Generator:
204
  log("ERROR", f"Error in updating mesh: {e}")
205
  time.sleep(5)
206
 
207
- history = rodin_history(task_uuid, self.token)
208
  try:
 
209
  preview_image = next(reversed(history.items()))[1]["preview_image"]
210
  except Exception as e:
211
  log("ERROR", f"Error in generating mesh: {history}")
212
- raise e
 
213
  response = requests.get(preview_image, stream=True)
214
  if response.status_code == 200:
215
  # 创建一个PIL Image对象
 
5
  import random
6
  import base64
7
  import io
8
+ import PIL
9
  from PIL import Image
10
  from io import BytesIO
11
  import gradio as gr
 
56
 
57
  def crop_image(image, type):
58
  if image == None:
59
+ raise gr.Error("Please generate the object first")
60
  new_image_width = 360 * (11520 // 720) # 每隔720像素裁切一次,每次裁切宽度为360
61
  new_image_height = 360 # 新图片的高度
62
  new_image = Image.new('RGB', (new_image_width, new_image_height))
 
108
  return response.json()
109
 
110
  def load_image(img_path):
111
+ try:
112
+ image = Image.open(img_path)
113
+ except PIL.UnidentifiedImageError as e:
114
+ raise gr.Error("Invalid Image Format")
115
 
116
  # 按比例缩小图像到长度为1024
117
  width, height = image.size
 
208
  log("ERROR", f"Error in updating mesh: {e}")
209
  time.sleep(5)
210
 
 
211
  try:
212
+ history = rodin_history(task_uuid, self.token)
213
  preview_image = next(reversed(history.items()))[1]["preview_image"]
214
  except Exception as e:
215
  log("ERROR", f"Error in generating mesh: {history}")
216
+ raise gr.Error("Busy connection, please try again later.")
217
+
218
  response = requests.get(preview_image, stream=True)
219
  if response.status_code == 200:
220
  # 创建一个PIL Image对象
app.py CHANGED
@@ -62,11 +62,8 @@ options = [
62
 
63
  example = [
64
  ["assets/00.png"],
65
- ["assets/07.png"],
66
  ["assets/08.png"],
67
- ["assets/11.png"],
68
  ["assets/13.png"],
69
- ["assets/21.png"],
70
  ["assets/24.PNG"],
71
  ["assets/30.png"],
72
  ["assets/42.png"],
 
62
 
63
  example = [
64
  ["assets/00.png"],
 
65
  ["assets/08.png"],
 
66
  ["assets/13.png"],
 
67
  ["assets/24.PNG"],
68
  ["assets/30.png"],
69
  ["assets/42.png"],