yeshavyas27 commited on
Commit
ef87252
β€’
1 Parent(s): 2dcbb49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -8,10 +8,10 @@ import re
8
  from torchvision.transforms.v2 import Resize
9
 
10
  parser = argparse.ArgumentParser()
11
- parser.add_argument("--cpu", action="store_true")
12
- args = parser.parse_args()
13
 
14
- DEVICE = "cuda"
15
  DTYPE = torch.float32 if DEVICE == "cpu" else torch.float16 # CPU doesn't support float16
16
  LATEST_REVISION = "2024-05-20"
17
 
@@ -78,7 +78,7 @@ def process_answer(img, answer):
78
  with gr.Blocks() as demo:
79
  gr.Markdown(
80
  """
81
- # πŸŒ” moondream
82
  """
83
  )
84
  with gr.Row():
@@ -94,4 +94,5 @@ with gr.Blocks() as demo:
94
  prompt.submit(answer_question, [img, prompt], output)
95
  output.change(process_answer, [img, output], ann, show_progress=False)
96
 
97
- demo.queue().launch(debug=True)
 
 
8
  from torchvision.transforms.v2 import Resize
9
 
10
  parser = argparse.ArgumentParser()
11
+ parser.add_argument("--cpu", action="store_true", help="Use CPU for computation")
12
+ args = parser.parse_args([])
13
 
14
+ DEVICE = "cuda" if torch.cuda.is_available() and not args.cpu else "cpu" # Determine device based on availability and argument
15
  DTYPE = torch.float32 if DEVICE == "cpu" else torch.float16 # CPU doesn't support float16
16
  LATEST_REVISION = "2024-05-20"
17
 
 
78
  with gr.Blocks() as demo:
79
  gr.Markdown(
80
  """
81
+ # πŸŒ” moondream-finetuned
82
  """
83
  )
84
  with gr.Row():
 
94
  prompt.submit(answer_question, [img, prompt], output)
95
  output.change(process_answer, [img, output], ann, show_progress=False)
96
 
97
+
98
+ demo.queue().launch(debug=False)