ifmain commited on
Commit
26ef7d6
1 Parent(s): 4ba36d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import time
2
 
3
  from diffusers import AutoPipelineForInpainting
@@ -12,6 +14,7 @@ import gradio as gr
12
  from gradio import components
13
  import difflib
14
 
 
15
  # Constants
16
  DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
17
 
@@ -34,6 +37,7 @@ def get_most_similar_string(target_string, string_array):
34
 
35
  return best_match
36
 
 
37
  def loadModels():
38
 
39
  yoloModel=YOLO('yolov8x-seg.pt')
@@ -99,6 +103,7 @@ def getSegments(yoloModel,img1):
99
 
100
  # Gradio UI
101
 
 
102
  def getDescript(image_captioner,img1):
103
  base64_img = image_to_base64(img1)
104
  caption = image_captioner(base64_img)[0]['generated_text']
@@ -125,6 +130,7 @@ def ChangeOBJ(sdxl_m,img1,response,mask1):
125
 
126
  yoloModel,sdxl,image_captioner=loadModels()
127
 
 
128
  def full_pipeline(image, target):
129
  img1 = Image.fromarray(image.astype('uint8'), 'RGB')
130
  allMask=getSegments(yoloModel,img1)
 
1
+ import spaces
2
+
3
  import time
4
 
5
  from diffusers import AutoPipelineForInpainting
 
14
  from gradio import components
15
  import difflib
16
 
17
+
18
  # Constants
19
  DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
20
 
 
37
 
38
  return best_match
39
 
40
+
41
  def loadModels():
42
 
43
  yoloModel=YOLO('yolov8x-seg.pt')
 
103
 
104
  # Gradio UI
105
 
106
+ @spaces.GPU
107
  def getDescript(image_captioner,img1):
108
  base64_img = image_to_base64(img1)
109
  caption = image_captioner(base64_img)[0]['generated_text']
 
130
 
131
  yoloModel,sdxl,image_captioner=loadModels()
132
 
133
+ @spaces.GPU
134
  def full_pipeline(image, target):
135
  img1 = Image.fromarray(image.astype('uint8'), 'RGB')
136
  allMask=getSegments(yoloModel,img1)