fix added
Browse files
app.py
CHANGED
@@ -1,34 +1,38 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import torchvision.transforms as transforms
|
3 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import io
|
5 |
-
import os
|
6 |
from fpdf import FPDF
|
7 |
import nest_asyncio
|
8 |
nest_asyncio.apply()
|
9 |
device='cuda' if torch.cuda.is_available() else 'cpu'
|
10 |
|
|
|
11 |
st.set_page_config(page_title="DermBOT", page_icon="🧬", layout="centered")
|
12 |
|
13 |
-
import torch
|
14 |
-
from torch import nn
|
15 |
-
from torchvision import transforms
|
16 |
from PIL import Image
|
17 |
-
from transformers import LlamaForCausalLM, LlamaTokenizer, BertModel, BertConfig
|
18 |
-
from eva_vit import create_eva_vit_g
|
19 |
-
import requests
|
20 |
-
from io import BytesIO
|
21 |
import os
|
22 |
-
from huggingface_hub import hf_hub_download
|
23 |
-
from transformers import BitsAndBytesConfig
|
24 |
-
from accelerate import init_empty_weights
|
25 |
-
import warnings
|
26 |
from transformers import logging
|
27 |
|
28 |
import torch
|
29 |
-
from torch.cuda.amp import autocast
|
30 |
from SkinGPT import SkinGPTClassifier
|
31 |
-
|
|
|
|
|
|
|
32 |
torch.set_default_dtype(torch.float32) # Main computations in float32
|
33 |
MODEL_DTYPE = torch.float16 if torch.cuda.is_available() else torch.float32
|
34 |
import warnings
|
@@ -43,9 +47,18 @@ import warnings
|
|
43 |
warnings.filterwarnings("ignore")
|
44 |
|
45 |
|
46 |
-
|
47 |
def get_classifier():
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
classifier = get_classifier()
|
51 |
|
|
|
|
|
|
|
1 |
import torch
|
2 |
+
import random
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
torch.manual_seed(42)
|
6 |
+
random.seed(42)
|
7 |
+
np.random.seed(42)
|
8 |
+
|
9 |
+
torch.backends.cudnn.deterministic = True
|
10 |
+
torch.backends.cudnn.benchmark = False
|
11 |
+
|
12 |
+
if torch.cuda.is_available():
|
13 |
+
torch.use_deterministic_algorithms(True)
|
14 |
+
torch.cuda.manual_seed_all(42)
|
15 |
+
|
16 |
+
import streamlit as st
|
17 |
import io
|
|
|
18 |
from fpdf import FPDF
|
19 |
import nest_asyncio
|
20 |
nest_asyncio.apply()
|
21 |
device='cuda' if torch.cuda.is_available() else 'cpu'
|
22 |
|
23 |
+
|
24 |
st.set_page_config(page_title="DermBOT", page_icon="🧬", layout="centered")
|
25 |
|
|
|
|
|
|
|
26 |
from PIL import Image
|
|
|
|
|
|
|
|
|
27 |
import os
|
|
|
|
|
|
|
|
|
28 |
from transformers import logging
|
29 |
|
30 |
import torch
|
|
|
31 |
from SkinGPT import SkinGPTClassifier
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
torch.set_default_dtype(torch.float32) # Main computations in float32
|
37 |
MODEL_DTYPE = torch.float16 if torch.cuda.is_available() else torch.float32
|
38 |
import warnings
|
|
|
47 |
warnings.filterwarnings("ignore")
|
48 |
|
49 |
|
50 |
+
@st.cache_resource
|
51 |
def get_classifier():
|
52 |
+
torch.use_deterministic_algorithms(True)
|
53 |
+
classifier = SkinGPTClassifier()
|
54 |
+
for module in [classifier.model.vit,
|
55 |
+
classifier.model.q_former,
|
56 |
+
classifier.model.llama]:
|
57 |
+
module.eval()
|
58 |
+
for param in module.parameters():
|
59 |
+
param.requires_grad = False
|
60 |
+
|
61 |
+
return classifier
|
62 |
|
63 |
classifier = get_classifier()
|
64 |
|