diff --git a/README.md b/README.md deleted file mode 100644 index d23b4aa..0000000 --- a/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Empowering-Investors-Hackathon - -## Submission Instruction: - 1. Fork this repository - 2. Create a folder with your Team Name - 3. Upload all the code and necessary files in the created folder - 4. Upload a **README.md** file in your folder with the below mentioned informations. - 5. Generate a Pull Request with your Team Name. (Example: submission-XYZ_team) - -## README.md must consist of the following information: - -#### Team Name - -#### Problem Statement - -#### Team Leader Email - - -## A Brief of the Prototype: - This section must include UML Diagrams and prototype description - -## Tech Stack: - List Down all technologies used to Build the prototype - -## Step-by-Step Code Execution Instructions: - This Section must contain a set of instructions required to clone and run the prototype so that it can be tested and deeply analyzed - -## What I Learned: - Write about the biggest learning you had while developing the prototype diff --git a/THOSE_IT_GUYS/.env b/THOSE_IT_GUYS/.env new file mode 100644 index 0000000..4fec6a9 --- /dev/null +++ b/THOSE_IT_GUYS/.env @@ -0,0 +1 @@ +PWD = "/home/ikshan/ikshan/SEBI" \ No newline at end of file diff --git a/THOSE_IT_GUYS/.gitignore b/THOSE_IT_GUYS/.gitignore new file mode 100644 index 0000000..a2d3078 --- /dev/null +++ b/THOSE_IT_GUYS/.gitignore @@ -0,0 +1,7 @@ +env +Utilities/translate/a.bin +Utilities/Wav_To_Text/__pycache__/ +Utilities/Yt_To_Wav/__pycache__/ +Utilities/Embeddings_Generate/__pycache__ +Pipeline/__pycache__/ +output.wav diff --git a/THOSE_IT_GUYS/Inf.csv b/THOSE_IT_GUYS/Inf.csv new file mode 100644 index 0000000..33e0280 --- /dev/null +++ b/THOSE_IT_GUYS/Inf.csv @@ -0,0 +1,51 @@ +Serial Number,Indian Name +1,Aarav Sharma +2,Priya Patel +3,Arjun Singh +4,Aanya Gupta +5,Rohan Mehta +6,Naina Verma +7,Krish Kapoor +8,Riya Khanna +9,Advait Mishra +10,Anika Joshi +11,Kabir Kumar +12,Ishita Choudhary +13,Dev Patel +14,Zara Khan +15,Vihaan Sharma +16,Aisha Reddy +17,Aarush Bansal +18,Anaya Gupta +19,Arnav Kapoor +20,Sara Verma +21,Advik Patel +22,Diya Singh +23,Vivaan Sharma +24,Kavya Yadav +25,Aaradhya Kumar +26,Yuvan Joshi +27,Anvi Kapoor +28,Aryan Khanna +29,Kiaan Mishra +30,Ananya Agarwal +31,Rehan Patel +32,Aadhya Gupta +33,Arusha Kapoor +34,Pranav Verma +35,Inaya Reddy +36,Ayaan Bansal +37,Alisha Gupta +38,Vihan Joshi +39,Ishika Yadav +40,Samaira Kumar +41,Kian Khanna +42,Myra Choudhary +43,Advay Verma +44,Aarohi Sharma +45,Aariz Khan +46,Avani Patel +47,Aayush Singh +48,Aarna Verma +49,Vansh Kapoor +50,Kiara Joshi \ No newline at end of file diff --git a/THOSE_IT_GUYS/Pipeline/main.py b/THOSE_IT_GUYS/Pipeline/main.py new file mode 100644 index 0000000..88be175 --- /dev/null +++ b/THOSE_IT_GUYS/Pipeline/main.py @@ -0,0 +1,32 @@ +from sklearn.pipeline import Pipeline +import pandas as pd + +import sys +import os + +# Add the parent directory to the module search path +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + +from Utilities.Wav_To_Text.wav_to_text import Wav_To_Text +from Utilities.Yt_To_Wav.yt_to_wav import Yt_To_Wav +from Utilities.Embeddings_Generate.main import Embeddings +from Utilities.Fin_Advise.main import Fin_Advise + +def trigger_pipeline(url): + pipeline = Pipeline([ + ('Generate .wav', Yt_To_Wav(url=url)), + ('Generate Text', Wav_To_Text()), + + ('Generate embeddings', Embeddings("Utilities/Models/doc2vec_model")), + ('Feeding Model with Infer Vectors', Fin_Advise("Utilities/Models/Fin_Advise_model.pkl")) + ]) + + # Scrape data from the URL and tokenize it + prediction = pipeline.fit_transform(str(url)) + print("AT THE END OF THE DAY I HAVE PREDICTED ->",prediction) + + os.remove("output.wav") + return prediction + +if __name__ == "__main__": + trigger_pipeline("https://youtu.be/3GGU2nE48mA?si=jAb6TCGiBTA6vFx3") \ No newline at end of file diff --git a/THOSE_IT_GUYS/Utilities/Embeddings_Generate/main.py b/THOSE_IT_GUYS/Utilities/Embeddings_Generate/main.py new file mode 100644 index 0000000..cea33e6 --- /dev/null +++ b/THOSE_IT_GUYS/Utilities/Embeddings_Generate/main.py @@ -0,0 +1,35 @@ +from sklearn.base import BaseEstimator, TransformerMixin +from gensim.models.doc2vec import Doc2Vec +from gensim.utils import simple_preprocess + + +class Embeddings(BaseEstimator, TransformerMixin): + + def __init__(self,model_path = "Utilities/Models/doc2vec_model"): + self.model_path = model_path + + def fit(self, X, y=None): + return self + + def transform(self, X): + print("Text recieved as X=",X) + + """ + Generate embeddings and return the embeddings + """ + + model = Doc2Vec.load(self.model_path) + # Preprocess the new paragraph + + new_paragraph_tokens = simple_preprocess(X) + + # Infer embeddings for the new paragraph + new_paragraph_vector = model.infer_vector(new_paragraph_tokens) + + # Now, `new_paragraph_vector` contains the embeddings for the new paragraph + print("Generated the infer vectors ") + print(new_paragraph_vector) + print("Moving to the next stage now") + return new_paragraph_vector + + diff --git a/THOSE_IT_GUYS/Utilities/Fin_Advise/__pycache__/main.cpython-310.pyc b/THOSE_IT_GUYS/Utilities/Fin_Advise/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000..14f85c3 Binary files /dev/null and b/THOSE_IT_GUYS/Utilities/Fin_Advise/__pycache__/main.cpython-310.pyc differ diff --git a/THOSE_IT_GUYS/Utilities/Fin_Advise/__pycache__/main.cpython-311.pyc b/THOSE_IT_GUYS/Utilities/Fin_Advise/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000..56ee969 Binary files /dev/null and b/THOSE_IT_GUYS/Utilities/Fin_Advise/__pycache__/main.cpython-311.pyc differ diff --git a/THOSE_IT_GUYS/Utilities/Fin_Advise/main.py b/THOSE_IT_GUYS/Utilities/Fin_Advise/main.py new file mode 100644 index 0000000..2fea737 --- /dev/null +++ b/THOSE_IT_GUYS/Utilities/Fin_Advise/main.py @@ -0,0 +1,44 @@ +from sklearn.base import BaseEstimator, TransformerMixin +from gensim.models.doc2vec import Doc2Vec +from gensim.utils import simple_preprocess +import joblib +import numpy as np + + +class Fin_Advise(BaseEstimator, TransformerMixin): + + def __init__(self,model_path = "Utilities/Models/Fin_Advise_model.pkl"): + self.model_path = model_path + + def fit(self, X, y=None): + return self + + def transform(self, X): + print("Inferred vectors recieved as ->", X) + print("Type of vectors = ", type(X)) + X = np.array(X) + X = [X] + + loaded_model = joblib.load(self.model_path) # Replace with the path to your saved model + + predictions = loaded_model.predict(X) + + print(predictions) + return predictions + +if __name__ == "__main__": + # Load the saved model + loaded_model = joblib.load("Utilities/Models/Fin_Advise_model.pkl")# Replace with the path to your saved model + print(loaded_model) + + # Make predictions + new_paragraph_vector = np.array([-0.36111203, -0.24920224, 0.62616724, -0.22456664, -0.06911723, + 0.7089261 , 0.3706734 , -0.50296277, -0.36461082, -0.35107777, + 0.13728353, 0.15671739, -0.0711432 , 1.1023189 , -0.49616072, + 0.18149595, -0.18339647, 0.27106458, 0.3413246 , 0.5554006 ]) + # Make predictions using the loaded model + new_paragraph_vector = [new_paragraph_vector] + predictions = loaded_model.predict(new_paragraph_vector) + + # Print the predictions + print(predictions) diff --git a/THOSE_IT_GUYS/Utilities/Models/Fin_Advise_model.pkl b/THOSE_IT_GUYS/Utilities/Models/Fin_Advise_model.pkl new file mode 100644 index 0000000..cd8530e Binary files /dev/null and b/THOSE_IT_GUYS/Utilities/Models/Fin_Advise_model.pkl differ diff --git a/THOSE_IT_GUYS/Utilities/Models/__pycache__/predict.cpython-311.pyc b/THOSE_IT_GUYS/Utilities/Models/__pycache__/predict.cpython-311.pyc new file mode 100644 index 0000000..37f3c7c Binary files /dev/null and b/THOSE_IT_GUYS/Utilities/Models/__pycache__/predict.cpython-311.pyc differ diff --git a/THOSE_IT_GUYS/Utilities/Models/doc2vec_model b/THOSE_IT_GUYS/Utilities/Models/doc2vec_model new file mode 100644 index 0000000..72b01de Binary files /dev/null and b/THOSE_IT_GUYS/Utilities/Models/doc2vec_model differ diff --git a/THOSE_IT_GUYS/Utilities/Wav_To_Text/test.py b/THOSE_IT_GUYS/Utilities/Wav_To_Text/test.py new file mode 100644 index 0000000..5950e30 --- /dev/null +++ b/THOSE_IT_GUYS/Utilities/Wav_To_Text/test.py @@ -0,0 +1,25 @@ +import pocketsphinx +from pocketsphinx import AudioFile + +audio_file = "/home/ikshan/ikshan/SEBI/Output.wav" + +# Define the configuration for CMU Sphinx +config = pocketsphinx.Decoder.default_config() +config.set_string('-hmm', 'path/to/acoustic_model') +config.set_string('-lm', 'path/to/language_model') +config.set_string('-dict', 'path/to/dictionary') + +# Initialize the decoder +decoder = pocketsphinx.Decoder(config) + +# Decode the audio file + +with AudioFile(audio_file) as audio: + audio.listen() + + # Perform ASR + result = decoder.decode(audio) + transcribed_text = result.hypothesis() + +print("Transcribed Text:") +print(transcribed_text) diff --git a/THOSE_IT_GUYS/Utilities/Wav_To_Text/wav_text_fast.py b/THOSE_IT_GUYS/Utilities/Wav_To_Text/wav_text_fast.py new file mode 100644 index 0000000..c123096 --- /dev/null +++ b/THOSE_IT_GUYS/Utilities/Wav_To_Text/wav_text_fast.py @@ -0,0 +1,18 @@ +import librosa +import torch +from transformers import Wav2Vec2ForCTC, Wav2Vec2Tokenizer + +audio, rate = librosa.load("output.wav", sr=16000) + +tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h") +model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h") + +input_values = tokenizer(audio, return_tensors="pt").input_values + +logits = model(input_values).logits + +prediction = torch.argmax(logits, dim=-1) + +transcription = tokenizer.batch_decode(prediction)[0] + +print(transcription) diff --git a/THOSE_IT_GUYS/Utilities/Wav_To_Text/wav_to_text.py b/THOSE_IT_GUYS/Utilities/Wav_To_Text/wav_to_text.py new file mode 100644 index 0000000..2cb4cce --- /dev/null +++ b/THOSE_IT_GUYS/Utilities/Wav_To_Text/wav_to_text.py @@ -0,0 +1,42 @@ +import speech_recognition as sr +from sklearn.base import BaseEstimator, TransformerMixin + +audio_file_path = 'output.wav' +recognizer = sr.Recognizer() + +class Wav_To_Text(BaseEstimator, TransformerMixin): + + def __init__(self, audio_file_path = "output.wav"): + self.audio_file_path = audio_file_path + return + + def fit(self, X=None, y=None): + return self + + def transform(self, X=None): + + with sr.AudioFile(self.audio_file_path) as source: + # Adjust for ambient noise if needed + recognizer.adjust_for_ambient_noise(source) + + # Listen to the audio and perform ASR + try: + audio_data = recognizer.record(source) + # Use the Google Web Speech API for ASR + text = recognizer.recognize_google(audio_data) + + print("Transcribed Text:") + print(text)\ + + print("Text generated now moving on to next stage") + return text + except sr.UnknownValueError: + print("Google Web Speech API could not understand the audio") + return None + except sr.RequestError as e: + print(f"Could not request results from Google Web Speech API; {e}") + return None + +if __name__ == "__main__": + wav = Wav_To_Text("output.wav") + wav.transform(X=None) \ No newline at end of file diff --git a/THOSE_IT_GUYS/Utilities/Yt_To_Wav/yt_to_wav.py b/THOSE_IT_GUYS/Utilities/Yt_To_Wav/yt_to_wav.py new file mode 100644 index 0000000..5fe5d56 --- /dev/null +++ b/THOSE_IT_GUYS/Utilities/Yt_To_Wav/yt_to_wav.py @@ -0,0 +1,50 @@ +import yt_dlp +from sklearn.base import BaseEstimator, TransformerMixin +import os +import glob + +class Yt_To_Wav(BaseEstimator, TransformerMixin): + + def __init__(self, url="https://youtu.be/3GGU2nE48mA?si=mhiwloo0USzZD-9R"): + self.url = url + + def fit(self, X, y=None): + return self + + def download_from_url(self): + print("in down from url") + ydl_opts = { + 'format': 'bestaudio/best', + 'postprocessors': [{ + 'key': 'FFmpegExtractAudio', + 'preferredcodec': 'wav', + }], + } + + with yt_dlp.YoutubeDL(ydl_opts) as ydl: + # info_dict = ydl.extract_info(self.url, download=True) + print(self.url) + ydl.download([self.url]) + # downloaded_filename = ydl.prepare_filename(info_dict) + + # Specify the absolute paths for the downloaded file and the new filename + directory = os.environ.get("PWD") + print(directory) + wav_files = glob.glob(os.path.join(directory, '*.wav')) + + # Print the list of found .wav files + for wav_file in wav_files: + os.rename(wav_file, "output.wav") + + return wav_files + + def transform(self, X): + print("in transform") + file_name = self.download_from_url() + print("File downloaded from url now moving to next stage") + return file_name + +# if __name__ == "__main__": +# yt = Yt_To_Wav("https://youtu.be/3GGU2nE48mA?si=lWhIBlzeMl19j1NW") + +# yt.transform(X=None) # Pass a placeholder value for X, as it's required by the TransformerMixin convention diff --git a/THOSE_IT_GUYS/Utilities/translate/translate.py b/THOSE_IT_GUYS/Utilities/translate/translate.py new file mode 100644 index 0000000..06fef48 --- /dev/null +++ b/THOSE_IT_GUYS/Utilities/translate/translate.py @@ -0,0 +1,12 @@ +from llama_cpp import Llama + +llm = Llama(model_path="./a.bin") + + +def translate(sentence): + output = llm(f"USER: Convert '{sentence}' to english. ASSISTANT: ", max_tokens=1028, echo=True) + output = output['choices'][0]['text'] + output = output[41+len(sentence):].replace('"','') + return output + + diff --git a/THOSE_IT_GUYS/image.png b/THOSE_IT_GUYS/image.png new file mode 100644 index 0000000..18904c1 Binary files /dev/null and b/THOSE_IT_GUYS/image.png differ diff --git a/THOSE_IT_GUYS/readme.md b/THOSE_IT_GUYS/readme.md new file mode 100644 index 0000000..e7aea69 --- /dev/null +++ b/THOSE_IT_GUYS/readme.md @@ -0,0 +1,137 @@ + +# FinClear + + +### Team Name +Those It Guys +### Problem Statement +Identifying Misleading Claims Made by Influencers +#### Team Leader Email +udaybeswal@gmail.com + + +## Brief of the Prototype + +### Objective + +This project prototype addresses the issue of misleading claims made by influencers, particularly in the financial domain. + +### Final Software UML + +![UML](image.png) + +### Prototype Overview +Prototype currently contains a Front-End made using `Streamlit`.The frontend takes a youtube url and the name of the influencer(just for demonstartion purpose) as the input and upon pressing the check button a multi-stage pipeline is triggered. Along with the pipeline a seperate check is run to check if an influencer is registered under SEBI or not. Since no such data was available publicly we are using a custom csv file. + +#### 1. Video to Audio Conversion +- **Input**: YouTube URL +- **Action**: Uses `yt_dlp` to extract the audio and generate a .wav file from the video. + +#### 2. Automatic Speech Recognition (ASR) +- **Input**: .wav audio file +- **Action**: Utilizes the `speech_recognition` library to perform ASR on the audio, transcribing spoken words into text. + +#### 3. Text Embeddings +- **Input**: Extracted text +- **Action**: Generates embeddings of generated text using a Doc2Vec model trained on the `Sentiment Analysis for Financial News` dataset from Kaggle. These embeddings represent the content's context. + +#### 4. Financial Advice Detection Model +- **Input**: Text embeddings +- **Action**: Feeds embeddings into the Fin_Advise_Model, which predicts whether the influencer is giving financial advice. Achieves an accuracy of `74.3%` using a Random Forest Classification model. The dataset for this model was generated through prompt engineering with the help of chatGPT. + + +## Tech Stack + +#### FRONTEND +Streamlit + +#### ML Models / Pipeline +Gensim - Doc2Vec + +Sklearn -Random Forest Classifier + +#### Transformer +Llama-Luna AI 7B model (For Hinglish Translation) + +#### External Tools +yt_dlp + +ffmpeg + +Hugging Face (Wav2Vec2ForCTCWav2Vec2Tokenizer) + +#### Datasets + +Doc2Vec Trained on +[Kaggle sentiment-analysis-for-financial-news](https://www.kaggle.com/datasets/ankurzing/sentiment-analysis-for-financial-news) + +Financial Advice Detector Model trained on [Dummy dataset](https://docs.google.com/spreadsheets/d/18hHYe4lsV5G01VWhHLSHGkhaH6F7u0jMnkQKCdvlLCk/edit?usp=sharing +) + +## Step By Step instructions to run locally + +Prerequisites: + - python + - pip + - A linux environment + + For the modules you can install both via pip: + +1) `pip install yt-dlp` + +2) `pip install ffmpeg-python` + + +3) **NOTE** : To run the project successfully you need to create a .env file in the root of the project with a variable name `PWD=` + +To run the project first install the necessary requirements using: + +4) Create a virtual environment using +`pip install virtualenv` and then `virtualenv env` + +5) Activate the virtual env `source env/bin/activate` + +6) `pip install -r requirements.txt` (Prefer a virtual environment for the same) + +And run: + +7) `streamlit run website.py` + +This would open up a web interface where you can provide the URL of the youtube video and the name of the influencer. + +Once you click the submit button it will trigger the model pipeline and check the content for any fraudlent claims and whether or not the particular influencer is registered or not. + +This will take some time according to the length of the video provided and display the results on the same page. + +## Learnings gained from this task + +- **Data Diversity Matters**: We discovered the critical importance of having a diverse and comprehensive dataset for training our model. It allowed us to capture a wider range of fraudulent behaviors. + +- **Feature Selection is Key**: Careful selection of features, including traditional financial indicators and emerging behavioral patterns, played a crucial role in the model's effectiveness. This balance helped in identifying both known and novel fraud attempts. + +- **Staying Vigilant for New Tricks**: The landscape of financial fraud is constantly evolving. We learned that we must continually monitor and adapt our model to detect and prevent new tricks and tactics employed by fraudsters. + +- **Ethical Considerations**: Dealing with sensitive financial information requires the utmost ethical standards. We made sure that our system adheres to strict ethical guidelines, ensuring the privacy and security of individuals' financial data. + +- **Fairness and Transparency**: We emphasized fairness and transparency in our system's operations. It's crucial that our model's decisions are clear and unbiased to protect innocent individuals from being wrongly flagged as fraudulent. + + + +## Future Aspects +We have developed a separate model to convert the general hinglish text to english so that our model can easily work with the data. + +It has been added in the current codebase but was not shown in the demo video for simplicity. To perform this conversion we are using generative AI capabilities of LunaAI - 7B LLM using python-llama. + +We are going to implement a stock analaysis model which checks the stocks mentioned in a video for any anomallies in volume, price and validity(i.e. registration under SEBI). + + +Currently we have only implemented a model to check for fraudulent claims but as we go forward we are going to add separate analysis models with weighted outputs that will be combined to give a final prediction. + +## Authors + +- [Ikshan Bhardwaj](https://github.com/ikshan-Tango/) +- [Akshat Jaimini](https://github.com/destrex271) +- [Utkarsh Tripathi](https://www.github.com/octokatherine) +- [Uday Beswal](https://github.com/udbe) + + diff --git a/THOSE_IT_GUYS/requirements.txt b/THOSE_IT_GUYS/requirements.txt new file mode 100644 index 0000000..716173e --- /dev/null +++ b/THOSE_IT_GUYS/requirements.txt @@ -0,0 +1,74 @@ +altair==5.0.1 +attrs==23.1.0 +blinker==1.6.2 +Brotli==1.0.9 +cachetools==5.3.1 +certifi==2023.7.22 +cffi==1.15.1 +charset-normalizer==3.2.0 +click==8.1.7 +ffmpeg==1.4 +ffmpeg-python==0.2.0 +filelock==3.12.2 +fsspec==2023.6.0 +future==0.18.3 +gensim==4.3.2 +gitdb==4.0.10 +GitPython==3.1.32 +huggingface-hub==0.16.4 +idna==3.4 +importlib-metadata==6.8.0 +Jinja2==3.1.2 +joblib==1.3.2 +jsonschema==4.19.0 +jsonschema-specifications==2023.7.1 +markdown-it-py==3.0.0 +MarkupSafe==2.1.3 +mdurl==0.1.2 +mutagen==1.46.0 +numpy==1.25.2 +packaging==23.1 +pandas==2.0.3 +Pillow==9.5.0 +protobuf==4.24.1 +pyarrow==13.0.0 +pycparser==2.21 +pycryptodomex==3.18.0 +pydeck==0.8.0 +Pygments==2.16.1 +Pympler==1.0.1 +python-dateutil==2.8.2 +pytz==2023.3 +pytz-deprecation-shim==0.1.0.post0 +PyYAML==6.0.1 +referencing==0.30.2 +regex==2023.8.8 +requests==2.31.0 +rich==13.5.2 +rpds-py==0.9.2 +safetensors==0.3.3 +scikit-learn==1.2.2 +scipy==1.11.2 +six==1.16.0 +smart-open==6.3.0 +smmap==5.0.0 +sounddevice==0.4.6 +SpeechRecognition==3.10.0 +streamlit==1.25.0 +tenacity==8.2.3 +threadpoolctl==3.2.0 +tokenizers==0.13.3 +toml==0.10.2 +toolz==0.12.0 +tornado==6.3.3 +tqdm==4.66.1 +transformers==4.32.0 +typing_extensions==4.7.1 +tzdata==2023.3 +tzlocal==4.3.1 +urllib3==2.0.4 +validators==0.21.2 +watchdog==3.0.0 +websockets==11.0.3 +yt-dlp==2023.7.6 +zipp==3.16.2 diff --git a/THOSE_IT_GUYS/website.py b/THOSE_IT_GUYS/website.py new file mode 100644 index 0000000..85439dd --- /dev/null +++ b/THOSE_IT_GUYS/website.py @@ -0,0 +1,65 @@ +import streamlit as st +import time +import csv +from Pipeline.main import trigger_pipeline + +# st.header("FinClear :money_with_wings:", anchor=False) +st.markdown("

FinClear

", + unsafe_allow_html=True) +st.markdown("

Choose who you beleive rightly!

", + unsafe_allow_html=True) + + +def processData(data): + print(data) + with st.spinner("Processing..."): + time.sleep(5) + st.success("Done!") + st.balloons() + + +container = st.container() +form = container.form("url_input") + + +def checkUrl(url): + if url.startswith("https://"): + return True + else: + return False + +def check_influencer(inf): + infs = [] + with open('./Inf.csv','r') as file: + csvFile = csv.reader(file) + for lines in csvFile: + infs.append(lines[1].lower()) + + if inf in infs: + print("Found") + return True + print("Not Found") + return False + + +with form: + input = form.text_input("Enter the URL:", placeholder="https://...") + input2 = form.text_input("Enter influencer name: ", placeholder="Financial Advisor X") + submitted = form.form_submit_button("Check", use_container_width=True) + + if submitted: + res = checkUrl(input) + if not res: + st.error("Enter a valid URL.") + else: + predicted = trigger_pipeline(input) + ext = " Influencer is not registered" + if check_influencer(input2): + ext = " Influencer is registered" + if predicted == 0: + st.success(f"The video is trustworthy.{ext}") + else: + st.error(f"The video is not trustworthy.{ext}") + + print("Done!") + # processData(input)