Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -68,13 +68,17 @@ client = OpenAI(
|
|
68 |
api_key=ACCESS_TOKEN,
|
69 |
)
|
70 |
|
71 |
-
# 데이터셋 로드
|
72 |
-
ds = load_dataset("lamm-mit/protein_secondary_structure_from_PDB",
|
73 |
-
token=ACCESS_TOKEN)
|
74 |
-
|
75 |
-
current_protein_result = None
|
76 |
-
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
def respond(
|
79 |
message,
|
80 |
history,
|
@@ -144,22 +148,33 @@ def analyze_prompt(message):
|
|
144 |
def search_protein_data(analysis, dataset):
|
145 |
"""분석 결과를 바탕으로 데이터셋에서 유사한 구조 검색"""
|
146 |
try:
|
147 |
-
#
|
148 |
keywords = extract_keywords(analysis)
|
|
|
149 |
|
|
|
|
|
|
|
|
|
|
|
150 |
# 유사도 점수 계산
|
151 |
scored_entries = []
|
152 |
for entry in dataset['train']:
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
#
|
157 |
scored_entries.sort(reverse=True)
|
158 |
-
return scored_entries[:3]
|
|
|
159 |
except Exception as e:
|
160 |
print(f"데이터 검색 중 오류: {str(e)}")
|
161 |
return []
|
162 |
-
|
163 |
def extract_parameters(analysis, similar_structures):
|
164 |
"""분석 결과와 유사 구조를 바탕으로 생성 파라미터 결정"""
|
165 |
try:
|
@@ -969,6 +984,40 @@ def extract_parameters_from_chat(chat_response):
|
|
969 |
print(f"파라미터 추출 중 오류: {str(e)}")
|
970 |
return None
|
971 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
972 |
with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
973 |
with gr.Row():
|
974 |
with gr.Column(scale=1):
|
|
|
68 |
api_key=ACCESS_TOKEN,
|
69 |
)
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
# 데이터셋 로드 및 구조 확인
|
73 |
+
try:
|
74 |
+
ds = load_dataset("lamm-mit/protein_secondary_structure_from_PDB",
|
75 |
+
token=ACCESS_TOKEN)
|
76 |
+
print("Dataset structure:", ds)
|
77 |
+
print("First entry example:", next(iter(ds['train'])))
|
78 |
+
except Exception as e:
|
79 |
+
print(f"Dataset loading error: {str(e)}")
|
80 |
+
raise
|
81 |
+
|
82 |
def respond(
|
83 |
message,
|
84 |
history,
|
|
|
148 |
def search_protein_data(analysis, dataset):
|
149 |
"""분석 결과를 바탕으로 데이터셋에서 유사한 구조 검색"""
|
150 |
try:
|
151 |
+
# 키워드 추출
|
152 |
keywords = extract_keywords(analysis)
|
153 |
+
print("Extracted keywords:", keywords)
|
154 |
|
155 |
+
# 데이터셋 구조 확인
|
156 |
+
if not dataset or 'train' not in dataset:
|
157 |
+
print("Invalid dataset structure")
|
158 |
+
return []
|
159 |
+
|
160 |
# 유사도 점수 계산
|
161 |
scored_entries = []
|
162 |
for entry in dataset['train']:
|
163 |
+
try:
|
164 |
+
score = calculate_similarity(keywords, entry)
|
165 |
+
scored_entries.append((score, entry))
|
166 |
+
except Exception as e:
|
167 |
+
print(f"Error processing entry: {str(e)}")
|
168 |
+
continue
|
169 |
|
170 |
+
# 결과 정렬 및 반환
|
171 |
scored_entries.sort(reverse=True)
|
172 |
+
return scored_entries[:3]
|
173 |
+
|
174 |
except Exception as e:
|
175 |
print(f"데이터 검색 중 오류: {str(e)}")
|
176 |
return []
|
177 |
+
|
178 |
def extract_parameters(analysis, similar_structures):
|
179 |
"""분석 결과와 유사 구조를 바탕으로 생성 파라미터 결정"""
|
180 |
try:
|
|
|
984 |
print(f"파라미터 추출 중 오류: {str(e)}")
|
985 |
return None
|
986 |
|
987 |
+
def download_checkpoint_files():
|
988 |
+
"""필요한 체크포인트 파일 다운로드"""
|
989 |
+
try:
|
990 |
+
import requests
|
991 |
+
|
992 |
+
# 체크포인트 파일 URL (실제 URL로 교체 필요)
|
993 |
+
dssp_url = "YOUR_DSSP_CHECKPOINT_URL"
|
994 |
+
og_url = "YOUR_OG_CHECKPOINT_URL"
|
995 |
+
|
996 |
+
# DSSP 체크포인트 다운로드
|
997 |
+
if not os.path.exists(dssp_checkpoint):
|
998 |
+
print("Downloading DSSP checkpoint...")
|
999 |
+
response = requests.get(dssp_url)
|
1000 |
+
with open(dssp_checkpoint, 'wb') as f:
|
1001 |
+
f.write(response.content)
|
1002 |
+
|
1003 |
+
# OG 체크포인트 다운로드
|
1004 |
+
if not os.path.exists(og_checkpoint):
|
1005 |
+
print("Downloading OG checkpoint...")
|
1006 |
+
response = requests.get(og_url)
|
1007 |
+
with open(og_checkpoint, 'wb') as f:
|
1008 |
+
f.write(response.content)
|
1009 |
+
|
1010 |
+
print("Checkpoint files downloaded successfully")
|
1011 |
+
except Exception as e:
|
1012 |
+
print(f"Error downloading checkpoint files: {str(e)}")
|
1013 |
+
raise
|
1014 |
+
|
1015 |
+
# 시작 시 체크포인트 파일 확인 및 다운로드
|
1016 |
+
try:
|
1017 |
+
download_checkpoint_files()
|
1018 |
+
except Exception as e:
|
1019 |
+
print(f"Warning: Could not download checkpoint files: {str(e)}")
|
1020 |
+
|
1021 |
with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
1022 |
with gr.Row():
|
1023 |
with gr.Column(scale=1):
|