ElifSB commited on
Commit
76c123c
ยท
verified ยท
1 Parent(s): 39fdfbf

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. app.py +60 -0
  3. dil_tespit_modeli.keras +3 -0
  4. dil_vektorlestirici.pkl +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ dil_tespit_modeli.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import tensorflow as tf
3
+ import pickle
4
+ import numpy as np
5
+ import neattext.functions as nfx
6
+
7
+ # 1. Page Configuration
8
+ st.set_page_config(page_title="AI Language Identifier", page_icon="๐ŸŒ", layout="centered")
9
+
10
+ # 2. Load Models and Necessary Files
11
+ @st.cache_resource
12
+ def load_models():
13
+ # Ensure these files are in the same directory on Hugging Face Space
14
+ model = tf.keras.models.load_model("dil_tespit_modeli.keras")
15
+ with open("dil_vektorlestirici.pkl", "rb") as f:
16
+ vectorizer = pickle.load(f)
17
+
18
+ # Original training labels
19
+ languages = ['Arabic', 'Danish', 'Dutch', 'English', 'French', 'German', 'Greek', 'Hindi', 'Italian', 'Kannada', 'Malayalam', 'Portuguese', 'Russian', 'Spanish', 'Swedish', 'Tamil', 'Turkish']
20
+ return model, vectorizer, languages
21
+
22
+ model, vectorizer, languages = load_models()
23
+
24
+ # 3. UI Design
25
+ st.title("๐ŸŒ Advanced Language Identification System")
26
+ st.markdown("""
27
+ ### Deep Learning Powered NLP Model
28
+ Enter any text below, and the AI will determine its language with high precision.
29
+ """)
30
+
31
+ # Text input area
32
+ user_input = st.text_area("Input Text for Analysis:", placeholder="e.g., Artificial Intelligence is transforming the world.", height=150)
33
+
34
+ # Detection Logic
35
+ if st.button("Detect Language"):
36
+ if user_input.strip():
37
+ with st.spinner('Analyzing patterns...'):
38
+ # Preprocessing
39
+ cleaned = nfx.remove_special_characters(user_input)
40
+ cleaned = nfx.remove_numbers(cleaned).lower()
41
+
42
+ # Vectorization
43
+ vectorized = vectorizer.transform([cleaned]).toarray()
44
+
45
+ # Prediction
46
+ prediction = model.predict(vectorized, verbose=0)
47
+ lang_index = np.argmax(prediction)
48
+ confidence = np.max(prediction) * 100
49
+ detected_lang = languages[lang_index]
50
+
51
+ # Display Results
52
+ st.success(f"### Detected Language: {detected_lang}")
53
+ st.progress(int(confidence))
54
+ st.info(f"**Confidence Score:** {confidence:.2f}%")
55
+ else:
56
+ st.warning("Please enter some text first to analyze.")
57
+
58
+ # Footer
59
+ st.markdown("---")
60
+ st.caption("Data Science Project | Deep Learning & Advanced NLP (ANN Model)")
dil_tespit_modeli.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa79f07712b931175f10eb9e8e113dc91951f7f4315b469642af6dd90d0a165c
3
+ size 121383292
dil_vektorlestirici.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:074c1d26c66aedead87b7aaa0793f5bd6e4aebeb4be65fa35a4a30d6b7be9803
3
+ size 601081