gdurkin commited on
Commit
8264471
1 Parent(s): c775d7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -2,11 +2,15 @@ import gradio as gr
2
  import numpy as np
3
  import torch
4
  from transformers import Mask2FormerImageProcessor, Mask2FormerForUniversalSegmentation
 
 
 
 
5
 
6
  # Load the model from Hugging Face
7
  model_name = "gdurkin/cdl_mask2former_hi_res_v3"
8
- processor = Mask2FormerImageProcessor.from_pretrained(model_name)
9
- model = Mask2FormerForUniversalSegmentation.from_pretrained(model_name)
10
  device = torch.device('cpu')
11
 
12
  # Define the inference function
 
2
  import numpy as np
3
  import torch
4
  from transformers import Mask2FormerImageProcessor, Mask2FormerForUniversalSegmentation
5
+ import os
6
+ access_token = os.getenv('HF_TOKEN')
7
+ from huggingface_hub import login
8
+ login(token = access_token)
9
 
10
  # Load the model from Hugging Face
11
  model_name = "gdurkin/cdl_mask2former_hi_res_v3"
12
+ processor = Mask2FormerImageProcessor.from_pretrained(model_name,token = access_token)
13
+ model = Mask2FormerForUniversalSegmentation.from_pretrained(model_name,token = access_token)
14
  device = torch.device('cpu')
15
 
16
  # Define the inference function