yonigozlan HF staff commited on
Commit
a4bd236
·
1 Parent(s): b67fc39

remove init compiled from gradio load

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -25,10 +25,6 @@ model_compiled = torch.compile(
25
  options={"triton.cudagraphs": True, "max_autotune": True},
26
  )
27
 
28
- url = "http://images.cocodataset.org/val2017/000000039769.jpg"
29
- image = Image.open(requests.get(url, stream=True).raw)
30
- inputs = processor(images=image, return_tensors="pt").to(device).to(torch.float16)
31
-
32
 
33
  @spaces.GPU
34
  def init_compiled_model():
@@ -41,6 +37,12 @@ def init_compiled_model():
41
  print(f"Model compiled in {time.time() - start_time:.2f} seconds.")
42
 
43
 
 
 
 
 
 
 
44
  css = """
45
  .feedback textarea {font-size: 24px !important}
46
  """
@@ -165,8 +167,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
165
  with gr.Row():
166
  submit = gr.Button(variant="primary")
167
 
168
- demo.load(init_compiled_model)
169
-
170
  example = gr.Examples(
171
  examples=[
172
  ["./football.mp4", 0.3, 640],
 
25
  options={"triton.cudagraphs": True, "max_autotune": True},
26
  )
27
 
 
 
 
 
28
 
29
  @spaces.GPU
30
  def init_compiled_model():
 
37
  print(f"Model compiled in {time.time() - start_time:.2f} seconds.")
38
 
39
 
40
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
41
+ image = Image.open(requests.get(url, stream=True).raw)
42
+ inputs = processor(images=image, return_tensors="pt").to(device).to(torch.float16)
43
+ init_compiled_model()
44
+
45
+
46
  css = """
47
  .feedback textarea {font-size: 24px !important}
48
  """
 
167
  with gr.Row():
168
  submit = gr.Button(variant="primary")
169
 
 
 
170
  example = gr.Examples(
171
  examples=[
172
  ["./football.mp4", 0.3, 640],