Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
-
#
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
-
|
| 4 |
-
tokenizer = AutoTokenizer.from_pretrained("snunlp/KR-FinBert-SC")
|
| 5 |
-
model = AutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC")
|
| 6 |
-
|
| 7 |
import os
|
| 8 |
import tensorflow as tf
|
| 9 |
from absl import logging
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# 환경 변수 설정
|
| 12 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # oneDNN 최적화 비활성화
|
| 13 |
|
|
@@ -25,61 +26,17 @@ if gpus:
|
|
| 25 |
except RuntimeError as e:
|
| 26 |
print(f"GPU 설정 오류: {e}")
|
| 27 |
|
| 28 |
-
# TensorFlow
|
| 29 |
-
print("TensorFlow 버전:", tf.__version__)
|
| 30 |
-
print("사용 가능한 장치:", tf.config.list_physical_devices())
|
| 31 |
-
|
| 32 |
-
import os
|
| 33 |
-
import tensorflow as tf
|
| 34 |
-
|
| 35 |
-
# oneDNN 최적화 비활성화
|
| 36 |
-
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
|
| 37 |
-
|
| 38 |
-
# GPU 비활성화 (CUDA 문제 해결 시)
|
| 39 |
-
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
| 40 |
-
|
| 41 |
-
# TensorFlow GPU 메모리 설정
|
| 42 |
-
gpus = tf.config.experimental.list_physical_devices('GPU')
|
| 43 |
-
if gpus:
|
| 44 |
-
try:
|
| 45 |
-
for gpu in gpus:
|
| 46 |
-
tf.config.experimental.set_memory_growth(gpu, True)
|
| 47 |
-
print("GPU 메모리 증가 허용 설정 완료")
|
| 48 |
-
except RuntimeError as e:
|
| 49 |
-
print(f"GPU 설정 오류: {e}")
|
| 50 |
-
|
| 51 |
-
# TensorFlow 실행 확인
|
| 52 |
print("TensorFlow 버전:", tf.__version__)
|
| 53 |
print("사용 가능한 장치:", tf.config.list_physical_devices())
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
FROM python:3.10-slim
|
| 57 |
-
|
| 58 |
-
# Install Python packages
|
| 59 |
-
RUN pip install --no-cache-dir pip==22.3.1 \
|
| 60 |
-
&& pip install --no-cache-dir datasets "huggingface-hub>=0.19" \
|
| 61 |
-
"hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0"
|
| 62 |
-
|
| 63 |
-
# Install system packages
|
| 64 |
-
RUN apt-get update && apt-get install -y \
|
| 65 |
-
git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1-mesa-glx \
|
| 66 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 67 |
-
|
| 68 |
-
# Work directory
|
| 69 |
-
WORKDIR /home/user/app
|
| 70 |
-
|
| 71 |
-
# Copy requirements and install additional Python packages
|
| 72 |
-
COPY requirements.txt .
|
| 73 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 74 |
-
|
| 75 |
-
# Copy source code
|
| 76 |
-
COPY . .
|
| 77 |
-
|
| 78 |
-
# Set default command
|
| 79 |
-
CMD ["streamlit", "run", "app.py"]
|
| 80 |
-
|
| 81 |
-
import streamlit as st
|
| 82 |
-
|
| 83 |
st.title("Hello, Streamlit!")
|
| 84 |
st.write("This is a sample Streamlit app.")
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face 모델 로드
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
+
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 4 |
import os
|
| 5 |
import tensorflow as tf
|
| 6 |
from absl import logging
|
| 7 |
|
| 8 |
+
# Hugging Face 모델 설정
|
| 9 |
+
tokenizer = AutoTokenizer.from_pretrained("snunlp/KR-FinBert-SC")
|
| 10 |
+
model = AutoModelForSequenceClassification.from_pretrained("snunlp/KR-FinBert-SC")
|
| 11 |
+
|
| 12 |
# 환경 변수 설정
|
| 13 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' # oneDNN 최적화 비활성화
|
| 14 |
|
|
|
|
| 26 |
except RuntimeError as e:
|
| 27 |
print(f"GPU 설정 오류: {e}")
|
| 28 |
|
| 29 |
+
# TensorFlow 정보 출력
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
print("TensorFlow 버전:", tf.__version__)
|
| 31 |
print("사용 가능한 장치:", tf.config.list_physical_devices())
|
| 32 |
|
| 33 |
+
# Streamlit 앱 인터페이스
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
st.title("Hello, Streamlit!")
|
| 35 |
st.write("This is a sample Streamlit app.")
|
| 36 |
|
| 37 |
+
# 입력 필드 추가
|
| 38 |
+
input_text = st.text_input("Enter some text:")
|
| 39 |
+
if st.button("Analyze"):
|
| 40 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 41 |
+
outputs = model(**inputs)
|
| 42 |
+
st.write("Model Output:", outputs.logits.tolist())
|