Repository navigation
Expand file tree
/
Copy pathgeneration_eval_v2.json
More file actions
5047 lines (5047 loc) · 475 KB
/
Copy pathgeneration_eval_v2.json
File metadata and controls
5047 lines (5047 loc) · 475 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"question": [
"Where is synthetic Captcha Dataset class written?",
"Where are different image transformations implemented",
"Where is dataloader for my ocr project used",
"How is ctc collate handled?",
"where am i calling gemini api?",
"Where do i handle logic of ensemble decision making of multiple intrusion detection models?",
"have i handled multiple workers on the IntrusionBackend",
"How is vocabulary generated and can be made better",
"Have i handled database samplers for any of my project if yes how have i handled them",
"How do i handle auth what method do i use?",
"Where can i live demo this project at?",
"Which project is about OCR",
"How do I run this Captcha project on my local machine",
"Do i have a project that handles real life captured images?",
"How do i get my fastapi project to run?",
"If tomorrow i built a new model for intrusion backend how would i add it?",
"What is the architecture of Intrusion Backend and how do the diff modules interact",
"How do I install CaptchaOCR?",
"What Python version does IntrusionBackend require?",
"How do I contribute to IntrusionBackend?",
"Which project uses pytorch",
"I wanted to mass send mails do i have a project for that?",
"I wanna build a fastapi for this new Pothole scanning project im building do i have a project i can use for reference",
"I need an OCR project.",
"I need a FastAPI template.",
"I need an email automation project.",
"I need a websocket implementation.",
"I need a PyTorch training pipeline.",
"What are the allowed Origins for my IntrusionBackend Project?",
"Where are CORS origins configured?",
"Where are environment variables loaded? in IntrusionBackend Project",
"Where is Docker configured for the IntrusionBackend?",
"Where is GitHub Actions defined?",
"Where is preprocessing and scaling configured for my models?",
"Do i have rate limits implemented somewhere for emails",
"How does the inference work?",
"How does live websocketing work in my projects",
"How does an image travel from upload to prediction?",
"How are websocket clients managed?",
"How does the training pipeline work in CaptchaOCR?",
"Do I have a Rust project?",
"Do I use Kubernetes?",
"Do I use Redis Streams?",
"Have I implemented GraphQL?",
"Which of my repositories use FastAPI?",
"Which projects use Gemini?",
"Which projects use PyTorch?",
"Which projects expose REST APIs?",
"generate_captcha",
"CaptchaDataset Generation",
"predict_intrusion",
"HermesGPT"
],
"answer": [
"The PyTorch Dataset class for your project is located in the `src/` directory. Specifically, it is defined in the file:\n\n**`src/captcha_dataset.py`**\n\nThis information is provided in the **Project Structure** section of your `README.md` file.",
"Based on the codebase provided, image transformations are implemented in the following files:\n\n* **`knowledge_base\\repos\\CaptchaOCR\\src\\generateCaptcha.py`**: This file contains the `generate_captcha` function, which applies a series of transformations including rotation, perspective warping, interference (lines and dots), noise, blur, JPEG recompression, contrast adjustments, and grayscale conversion.\n* **`knowledge_base\\repos\\CaptchaOCR\\src\\data.py`**: This file contains the `render_with_variation` function, which implements a nearly identical pipeline of transformations (rotation, perspective warp, interference, noise, blur, JPEG recompression, contrast, and grayscale conversion) to generate variations of CAPTCHA images.\n\nThe specific transformation helper functions (such as `perspective_warp`, `add_interference`, `add_noise_and_blur`, and `jpeg_recompress`) are utilized within these two files, though their specific definitions are not included in the provided context snippets.",
"In your **CaptchaOCR** project, the `DataLoader` is imported and used in the file `knowledge_base\\repos\\CaptchaOCR\\train_sanity.py`.\n\nAccording to the imports in that file:\n```python\nfrom torch.utils.data import DataLoader\n```\n\nIt is used to handle the data loading process for the training sanity check, likely in conjunction with the `CaptchaDataset` and `ctc_collate` function also imported in that file.",
"In your codebase, the CTC collation is handled by the `ctc_collate` function located in `src/collate.py`. \n\nAccording to the implementation, the function processes a batch of `(image_tensor, label_str, rel_path)` tuples and performs the following steps:\n\n1. **Images**: Stacks the image tensors into a single batch tensor of shape `[B, C, H, W_max]`.\n2. **Labels**: Encodes the label strings into tensors using an `encode_text` function, then concatenates them into a flat tensor (`targets_flat`) for CTC loss calculation.\n3. **Target Lengths**: Creates a tensor containing the lengths of each individual label sequence.\n4. **Input Lengths**: Calculates the input lengths based on the image width and a `total_stride` defined in your configuration (`cfg.total_stride`). It returns a tensor of shape `[B]` where each value is `W // cfg.total_stride`.\n5. **Paths**: Collects the relative paths into a list.\n\nThis function is designed to support the variable-length sequences required for CTC-based OCR training, as noted in your `README.md`. It is utilized in both your training pipeline (`train.py`) and your sanity check script (`train_sanity.py`).",
"You are calling the Gemini API in the file `knowledge_base\\repos\\HermesGPT\\hermesgpt.py`.\n\nSpecifically, the configuration and initialization occur in the following lines:\n\n* **Line 88:** `genai.configure(api_key=API_KEY)`\n* **Line 89:** `chat = genai.GenerativeModel('gemini-2.0-flash').start_chat(history=[])`\n\nThe `API_KEY` variable used for configuration is defined on line 20 of the same file.",
"Based on the provided codebase, the ensemble decision-making logic is handled through a **hierarchical pipeline** where the **LightGBM** model acts as the final arbiter (or \"Veto\").\n\nHere is where this logic is implemented:\n\n* **API/Service Level:** The logic is defined in the `POST /intrusiondetection/predict/hybrid` endpoint. According to `documentation.md`, this endpoint uses a hierarchical pipeline where unsupervised models (Autoencoder or Isolation Forest) flag the flow, and supervised models (LightGBM, FFNN, etc.) are then invoked. **LightGBM** is explicitly designated to provide the final \"Veto\" to determine if the flow is truly an attack.\n* **Evaluation/Stats Level:** The logic for how the system interprets these results is implemented in `knowledge_base\\repos\\IntrusionBackend\\stats.py` within the `generate_stats()` function. Specifically, lines 25\u201329 demonstrate the decision-making process:\n ```python\n # Logic: If status is Attack Detected, use the LightGBM prediction. \n # Otherwise, it's Benign (0).\n if result[\"status\"] == \"Attack Detected\":\n predicted = result.get(\"supervised\", {}).get(\"lightgbm\", 0)\n else:\n predicted = 0\n ```\n\nAdditionally, `documentation.md` confirms that LightGBM is the \"Final Veto\" model within the system architecture, supported by other models like FFNN, XGBoost, and Logistic Regression for ensemble verification.",
"Based on the provided codebase context, there is no information indicating that you have configured or handled multiple workers for the `IntrusionBackend`.\n\nThe `docker-compose.yml` file defines a single service named `intrusion-tracker` that maps port `8000` to `8000`, but it does not specify any configuration for worker processes (such as Gunicorn or Uvicorn worker settings).",
"Based on the provided codebase for the **CaptchaOCR** repository, here is how the vocabulary is currently handled and how it could potentially be improved.\n\n### How Vocabulary is Currently Handled\nThe vocabulary system is centralized and integrated into the training pipeline:\n\n* **Definition:** The vocabulary is defined in the project's configuration (`cfg.chars`). It supports 63 classes, which includes the necessary characters for CAPTCHA generation and a **CTC blank token** (index 0) required for Connectionist Temporal Classification (CTC) loss.\n* **Encoding/Decoding:** The system uses an `itos` (index-to-string) mapping to convert model outputs back into readable text.\n* **Training Integration:** During training, the `main()` function in `train.py` prints the vocabulary size and the first 10 characters/itos mappings to verify the setup. The `CRNN` model is initialized with `vocab_size=vocab_size()`.\n* **CTC Support:** The system is specifically designed to handle variable-length sequences using the CTC loss function, which requires the blank token to handle repeated characters or transitions between characters.\n\n### How It Can Be Made Better\nBased on the current implementation, here are a few ways to improve or harden the vocabulary system:\n\n1. **Dynamic Vocabulary Discovery:** Currently, the vocabulary seems to be hardcoded in the configuration. You could implement a script that scans the generated dataset (or a provided corpus) to automatically build the vocabulary. This ensures that if you change the character set in `generateCaptcha.py`, the model configuration updates automatically, preventing index-out-of-bounds errors.\n2. **Character Frequency Balancing:** If certain characters appear significantly less often than others in your synthetic CAPTCHA generation, the model may struggle to recognize them. You could analyze the distribution of characters in your training set and adjust the `generate_captcha` function to sample characters based on an inverse frequency distribution to ensure the model sees \"harder\" characters more often.\n3. **Special Token Handling:** If you plan to expand the CAPTCHA complexity (e.g., adding mathematical symbols or case-sensitive alphanumeric characters), ensure the vocabulary system explicitly handles these as distinct classes. You could add a \"validation\" step in the training pipeline that checks if the generated CAPTCHA text contains characters outside the defined vocabulary before passing them to the model.\n4. **Robustness to Noise:** Since the model uses CTC, the vocabulary performance is heavily tied to how well the model distinguishes between the \"blank\" token and actual characters. You could improve the vocabulary's effectiveness by experimenting with different \"blank\" token weights or by adding \"unknown\" or \"noise\" tokens if you find the model is misclassifying background interference as characters.\n5. **Centralized Mapping File:** Instead of relying on `cfg.chars`, you could save the `stoi` (string-to-index) and `itos` mappings as a JSON file alongside your model checkpoints. This would ensure that inference scripts always use the exact character mapping that the model was trained on, preventing decoding errors if the configuration file is modified later.\n\n**Note:** The information regarding the specific implementation of the vocabulary mapping (the `stoi`/`itos` dictionary creation) is not explicitly detailed in the provided snippets, but the training loop confirms it is accessed via `vocab_size()` and `cfg.chars`.",
"Yes, you have implemented a database sampler in your **IntrusionBackend** project.\n\nAccording to `knowledge_base\\repos\\IntrusionBackend\\utils.py`, you handle sampling through a function named `sampler(target_class)`. Here is how it works:\n\n1. **Filtering**: It filters a global dataframe (`df`) to find rows where the \"Attack\" column matches the provided `target_class`.\n2. **Random Sampling**: It takes a random sample of 1 from the filtered results using `.sample(1)`.\n3. **Validation**: It checks if the resulting dataframe is empty (`height == 0`) and raises a `ValueError` if no data is found for that class.\n4. **Extraction**: \n * It retrieves the `original_index` of the sampled row.\n * It drops the \"Attack\" and \"original_index\" columns from the sample.\n * It converts the remaining features into a NumPy array.\n5. **Return**: It returns both the feature array and the original index.",
"Based on the provided codebase, the authentication method depends on which repository you are referring to:\n\n### For **HermesGPT**:\nYou are using **OAuth 2.0** for Gmail integration. According to `knowledge_base\\repos\\HermesGPT\\hermesgpt.py`, the project utilizes:\n* `google-auth-oauthlib` and `google-auth` libraries.\n* The `InstalledAppFlow` class to handle the authorization flow.\n* The scope `https://www.googleapis.com/auth/gmail.send` to send emails via the Gmail API.\n\n### For **IntrusionBackend**:\nAccording to `knowledge_base\\repos\\IntrusionBackend\\documentation.md`, the protected endpoints require a **Bearer Token** for authentication. \n\nIf you are referring to a specific part of the code not mentioned here, please let me know!",
"Based on the provided codebase context, a live demo is available for the **IntrusionBackend** project. You can explore it at:\n\n[https://www.mohakapoor.in/projects/IntrusionDetection](https://www.mohakapoor.in/projects/IntrusionDetection)\n\n(Source: `knowledge_base\\repos\\IntrusionBackend\\README.md`)",
"The project about OCR is **CaptchaOCR**.\n\nAccording to the `README.md` file in the `CaptchaOCR` repository, it implements an end-to-end CAPTCHA OCR system that uses a CRNN (CNN + RNN) architecture for sequence recognition and CTC (Connectionist Temporal Classification) loss for training.",
"To run the **CaptchaOCR** project on your local machine, you should follow these steps based on the provided codebase:\n\n### 1. Prerequisites\n* **Environment:** Ensure you have **PyTorch** installed. The project supports CUDA for GPU acceleration, but will fall back to CPU if a GPU is not available (as seen in `inference.py`).\n* **Dependencies:** You will need standard Python libraries for image processing and data handling, specifically `PIL` (Pillow), `numpy`, and `cv2` (OpenCV), which are utilized in `src/generateCaptcha.py`.\n\n### 2. Project Setup\n* **Directory Structure:** Ensure your local directory matches the structure defined in the `README.md`. Specifically, you need the `src/` folder containing your configuration and model scripts, and a `checkpoints/` directory.\n* **Model Checkpoint:** The `inference.py` script explicitly requires a trained model file. You must place your trained model at:\n `checkpoints/best_model.pth`\n (If this file is missing, the `main()` function in `inference.py` will fail).\n\n### 3. Running Inference\nThe project provides an `inference.py` script that handles the generation of test CAPTCHAs and evaluates the model. To run it:\n1. Open your terminal in the root directory of the project.\n2. Execute the script:\n ```bash\n python inference.py\n ```\n3. **What this script does:**\n * It initializes the device (GPU/CPU).\n * It loads your model from `checkpoints/best_model.pth`.\n * It generates 4 random test CAPTCHAs using the enhanced generation logic.\n * It runs the images through the CRNN model.\n * It outputs a table comparing the **Target** text vs. the **Prediction** and calculates overall and character-level accuracy.\n * It saves a visualization of the results in the `Metrics/` directory.\n\n### 4. Training (If needed)\nIf you do not have a trained model yet, the project includes a `train.py` script in the root directory. Based on the `README.md`, this is the main entry point for training your model using the dataset structure provided in `Dataset_test/` or `Dataset/`.\n\n### Important Notes:\n* **Configuration:** Check `src/config.py` to ensure your hyperparameters (like image dimensions and character sets) match your training configuration.\n* **Data:** Ensure your `Dataset_test/` folder is populated as per the `README.md` structure if you intend to perform training or validation locally.",
"Based on the provided codebase, you have a project called **CaptchaOCR** that implements an end-to-end CAPTCHA OCR system.\n\nAccording to the `README.md` in the `CaptchaOCR` repository, the project is designed to \"recognize text in CAPTCHA images.\" While it uses **synthetic CAPTCHA generation** for training data, the system is built as an OCR pipeline (using CRNN architecture and CTC loss) intended for CAPTCHA recognition.\n\nThere is no mention of a project specifically dedicated to handling \"real-life\" (non-synthetic) captured images in the provided context.",
"To run your FastAPI project, you should use **Uvicorn**, which is listed as part of your tech stack in `README.md` and included in your `requirements.txt`.\n\nBased on the codebase context, here is how your project is structured and how to run it:\n\n### 1. Prerequisites\nEnsure you have installed the dependencies listed in `requirements.txt`. You can typically do this via:\n```bash\npip install -r requirements.txt\n```\n\n### 2. Running the Application\nYour main FastAPI application is initialized in `router.py`:\n```python\napp = FastAPI(title=\"Intrusion Detection API\", version=\"1.0.0\")\nconfigure_cors(app)\n```\n\nTo start the server, you would use the `uvicorn` command pointing to the `app` object within `router.py`. Assuming your file is named `router.py`, run the following command in your terminal from the root directory:\n\n```bash\nuvicorn router:app --reload\n```\n\n### Key Details:\n* **Entry Point**: The application is defined in `router.py`.\n* **CORS**: The `configure_cors` function from `cors.py` is automatically applied to your `app` instance in `router.py`, ensuring that your specified origins (like `https://mohakapoor.in`) are allowed to communicate with your backend.\n* **Environment**: You are using `python-dotenv` (as seen in `router.py` and `requirements.txt`), so ensure you have your `.env` file configured if your application requires specific environment variables to function.\n* **Deployment**: Your `README.md` also mentions that the project supports **Docker** for containerization. If you prefer to run it via Docker, you can use the `dockerfile` provided in the repository.",
"To add a new model to your **IntrusionBackend** project, you should follow the architectural patterns established in your existing codebase. Based on the provided documentation, here is how you would integrate it:\n\n### 1. Implement the Model Endpoint\nYour backend exposes specific endpoints for model inference. You should add a new endpoint to your FastAPI application (likely in the same module where the other model endpoints are defined). \n\nAccording to `documentation.md`, you currently have direct model endpoints such as:\n* `POST /predict/logreg`\n* `POST /predict/lightgbm`\n* `POST /predict/ffnn`\n\nYou would add a new route for your model, for example:\n```python\n@app.post(\"/predict/your_new_model_name\")\nasync def predict_new_model(data: YourDataSchema):\n # Logic to load your model and perform inference\n ...\n```\n\n### 2. Integrate into the Hybrid Pipeline (Optional)\nIf you want your new model to be part of the **Hybrid Detection** pipeline (the `POST /intrusiondetection/predict/hybrid` endpoint), you will need to update the hierarchical logic. \n\nAs noted in `documentation.md`, the hybrid pipeline currently uses:\n* **Unsupervised layer:** Autoencoder or Isolation Forest.\n* **Supervised layer:** LightGBM, FFNN, etc.\n\nIf your new model is a supervised classifier, you would update the logic in the hybrid prediction function to include your model in the ensemble or the \"Veto\" process currently handled by LightGBM.\n\n### 3. Deployment Considerations\nSince your project uses Docker, once you have implemented the code changes:\n* **Update the container:** You will need to rebuild your Docker image to include the new model files and dependencies. Your `docker-compose.yml` indicates the service is named `intrusion-api` and uses the current directory for the build context.\n* **Environment Variables:** If your new model requires specific paths or configuration, ensure you update your `.env` file, which is referenced in your `docker-compose.yml`.\n\n### Summary of Steps:\n1. **Develop:** Add the model inference logic in your Python backend code.\n2. **Expose:** Create a new `POST` endpoint for the model.\n3. **Integrate:** Update the hybrid pipeline logic if you want the model to participate in the automated detection flow.\n4. **Deploy:** Rebuild the `intrusion-api` container using `docker-compose build` to reflect the changes.\n\nFor specific implementation details regarding the existing model structure, you should refer to the source files in your repository (which were not provided in the context, but would be located in your project's source directory).",
"The **Intrusion Tracker Backend** is a high-performance network security monitoring system built with FastAPI. Its architecture is centered around a **hierarchical machine learning pipeline** designed to detect and classify network intrusions in real-time.\n\n### Architectural Overview\nAccording to the `documentation.md` file, the system utilizes a multi-stage approach to intrusion detection:\n\n1. **Unsupervised Anomaly Detection**: The pipeline begins by using models such as an **Autoencoder** or **Isolation Forest** to flag potentially suspicious network flows.\n2. **Supervised Classification**: If the anomaly detection stage flags a flow, the system triggers a secondary layer of supervised models, including **LightGBM** and **FFNN (Feed-Forward Neural Network)**.\n3. **Veto Mechanism**: The **LightGBM** model acts as the final \"Veto\" authority to determine whether the flagged flow is definitively an attack.\n\n### Module Interaction\nThe interaction between these modules is primarily exposed through the `/intrusiondetection/predict/hybrid` endpoint. The workflow follows this logic:\n\n* **Trigger**: A request is sent to the hybrid prediction endpoint.\n* **Filtering**: The system first passes the data through the unsupervised models.\n* **Escalation**: If the unsupervised models identify an anomaly, the data is passed to the supervised models for detailed classification.\n* **Decision**: The supervised models (specifically LightGBM) process the data to provide the final classification result, which is then returned to the user.\n\nAdditionally, the system provides direct access to individual models (`/predict/logreg`, `/predict/lightgbm`, `/predict/ffnn`) for specific use cases or testing, bypassing the hierarchical pipeline.\n\nFor testing purposes, the system also supports a `hybrid_by_index` endpoint, which allows you to run samples from the `unscaled_test.parquet` dataset through this hierarchical pipeline.",
"To install the environment for **CaptchaOCR**, follow these steps as outlined in the `README.md` file:\n\n### 1. Install PyTorch\nInstall PyTorch with CUDA support (adjust the version based on your system requirements):\n```bash\npip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu128\n```\n\n### 2. Install Dependencies\nInstall the remaining required packages:\n```bash\npip install captcha pandas pillow\n```\n\nAfter completing these steps, you can proceed to generate your training dataset by running `python data.py` from the `src` directory, and then start the training pipeline using `python train.py`.",
"Based on the provided codebase context, there is no information specifying the required Python version for the **IntrusionBackend** repository. \n\nThe `manifest.json` file confirms that the project uses Python as its language, but it does not define a specific version requirement.",
"Based on the provided codebase context, there is no explicit \"CONTRIBUTING.md\" file or specific instructions on how to contribute to the **IntrusionBackend** repository.\n\nHowever, the following information is available regarding the project:\n\n* **Owner**: The repository is owned by `mohakapoor` (found in `manifest.json`).\n* **Branching**: The project is currently tracking the `dev` branch (`manifest.json`).\n* **Technology Stack**: It is a Python-based project using FastAPI for the backend (`documentation.md`, `manifest.json`).\n* **Deployment**: The project uses Docker, as evidenced by the `docker-compose.yml` file.\n\nIf you are looking to collaborate, you may want to reach out to the owner, `mohakapoor`, or check the repository's main page for standard contribution guidelines (such as pull request templates or issues) that were not included in the provided documentation files.",
"Both projects in your codebase use PyTorch:\n\n* **CaptchaOCR**: This project uses PyTorch with CUDA support for its CRNN (CNN + RNN) architecture and CTC-based sequence modeling (as stated in `knowledge_base\\repos\\CaptchaOCR\\README.md`).\n* **IntrusionBackend**: This project lists PyTorch as part of its ML/DL tech stack (as stated in `knowledge_base\\repos\\IntrusionBackend\\README.md`).",
"Yes, you have a project for that. **HermesGPT** is specifically designed as an automated internship outreach bot that includes features for mass/batch email processing.\n\nAccording to the `README.md` file, your project includes the following relevant features:\n\n* **Batch Processing**: The system is capable of sending emails in batches with randomized delays to prevent spam detection.\n* **Automated Email Sending**: It uses the Gmail API to send emails with attachments.\n* **Email Verification**: It utilizes SMTP and the Maileroo API to validate emails before sending them.\n* **Database Management**: It tracks outreach progress and stores recruiter data in PostgreSQL.\n\nAdditionally, the `initial_outreach` function in `hermesgpt.py` handles the generation of personalized cold emails using Gemini AI, which are then intended to be sent via these automated processes.",
"Yes, you have a project in your codebase that you can use as a reference for building a FastAPI application: the **IntrusionBackend** repository.\n\nThis project is an enterprise-grade Network Intrusion Detection System (NIDS) built with FastAPI. You can refer to the following files to understand how to structure your own FastAPI project:\n\n* **`router.py`**: This is the main entry point for the application. It demonstrates how to initialize the `FastAPI` app, configure routes using `APIRouter`, handle WebSockets, and manage dependencies.\n* **`cors.py`**: This file shows how to configure `CORSMiddleware` to handle cross-origin requests securely.\n* **`documentation.md`**: This file provides a clear overview of the project structure, explaining the roles of different files like `predict.py` (for inference logic) and `utils.py` (for data processing), which may be useful for your Pothole scanning project's backend architecture.\n* **`requirements.txt`**: This file lists the necessary dependencies (including `fastapi` and `uvicorn`) that you will likely need for your own project.\n\nYou can find these files in the `knowledge_base\\repos\\IntrusionBackend\\` directory.",
"You have an OCR project in your codebase called **CaptchaOCR**.\n\nBased on the project documentation in `knowledge_base\\repos\\CaptchaOCR\\README.md`, here are the details:\n\n* **Purpose:** It is an end-to-end CAPTCHA OCR system designed to recognize text in CAPTCHA images.\n* **Architecture:** It uses a **CRNN (CNN + RNN)** architecture for sequence recognition.\n* **Training:** It utilizes **synthetic CAPTCHA generation** for training data and **CTC (Connectionist Temporal Classification)** loss.\n* **Technology Stack:** It is built with **PyTorch** and supports CUDA for GPU acceleration.\n* **Interface:** The project includes a Gradio-based web interface (`app.py`) that allows you to generate CAPTCHAs and solve them using the model.\n\nThe project is intended for educational purposes, and you are free to use and modify it as needed.",
"Based on the provided codebase, your project already has a FastAPI template established in `router.py` and `cors.py`.\n\nHere is how your current FastAPI application is structured:\n\n### 1. Main Application Setup (`router.py`)\nYour main application is initialized in `router.py` using `FastAPI`. It also integrates the CORS configuration:\n\n```python\nfrom fastapi import FastAPI, APIRouter\nfrom cors import configure_cors\n\napp = FastAPI(title=\"Intrusion Detection API\", version=\"1.0.0\")\n\n# Configure CORS middleware\nconfigure_cors(app)\n\n# Define your routes\nrouter = APIRouter(prefix=\"/intrusiondetection\")\n```\n\n### 2. CORS Configuration (`cors.py`)\nYour project uses a dedicated `configure_cors` function to handle middleware settings, which is a clean way to manage security for your origins:\n\n```python\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom fastapi import FastAPI\n\ndef configure_cors(app: FastAPI) -> None:\n allowed_origins = [\n \"https://mohakapoor.in\",\n \"https://sisyphus.mohakapoor.in\",\n \"http://mohakapoor.in\",\n \"http://sisyphus.mohakapoor.in\",\n \"http://localhost:8000\"\n ]\n \n app.add_middleware(\n CORSMiddleware,\n allow_origins=allowed_origins,\n allow_credentials=True,\n allow_methods=[\"GET\", \"POST\", \"PUT\", \"DELETE\", \"OPTIONS\", \"PATCH\"],\n allow_headers=[\"*\"],\n expose_headers=[\"*\"],\n max_age=3600\n )\n```\n\n### Recommended Project Structure\nAccording to your `documentation.md`, you should maintain this organization for your FastAPI project:\n\n* **`router.py`**: Main application entry point, HTTP routes, and WebSocket logic.\n* **`cors.py`**: Middleware configuration.\n* **`predict.py`**: Model loading and inference logic.\n* **`utils.py`**: Data processing and utility functions.\n* **`dockerfile`**: For containerizing your FastAPI application.\n\nIf you are looking to start a new module, you can follow the pattern in `router.py` by importing `APIRouter` and attaching it to your main `app` instance.",
"You already have an email automation project in your codebase called **HermesGPT**. It is an intelligent automation tool specifically designed to streamline the process of reaching out to recruiters for internship opportunities.\n\nAccording to the `README.md` and `hermesgpt.py` files, here is what your project currently does:\n\n### Key Features\n* **AI-Powered Personalization**: Uses Gemini AI to generate tailored cold emails based on your resume and the recruiter's details.\n* **Automated Sending**: Integrates with the Gmail API to send emails with your resume attached.\n* **Email Verification**: Validates email addresses using SMTP and the Maileroo API before sending.\n* **Database Management**: Uses PostgreSQL to store recruiter information and track your outreach progress (marking them as contacted).\n* **Batch Processing**: Sends emails in batches with randomized delays to help prevent spam detection.\n\n### How to get it running\nBased on the **Setup Instructions** in your `README.md`:\n1. **Clone and Install**: Clone the repository and install dependencies via `pip install -r requirements.txt`.\n2. **Database**: Set up a PostgreSQL database using the `recruiters` table schema provided in the documentation.\n3. **Gmail API**: Enable the Gmail API in the Google Cloud Console, download your `credentials.json`, and place it in the project directory.\n4. **Configuration**: Add your Gemini AI API key to the `API_KEY` variable.\n5. **Data**: Prepare a `recruiters.csv` file with the required columns (Email, Name, Company, Title).\n6. **Execution**: Run `python main.py` to start the authentication and outreach process.\n\nThe core logic for generating the emails is located in `hermesgpt.py` within the `initial_outreach` function, which prompts the AI to create a professional, custom-tailored email under 200 words.",
"The WebSocket implementation for your project is located in `router.py`. It provides a streaming service that processes datasets in batches of 100 rows and returns real-time accuracy telemetry and latency statistics.\n\n### Implementation Details\nThe endpoint is defined as `WS /intrusiondetection/ws/stream`. The logic is handled by the `websocket_stream` function in `router.py` (lines 191-315).\n\n#### How it works:\n1. **Connection & Auth**: Upon connecting, the client must send an initialization JSON containing a `command` (\"start\"), an `API_TOKEN` for authentication, and an optional `start_at` index.\n2. **Batch Processing**: The server iterates through the dataset using `predict.predict_attack_by_idx` (from `predict.py`) in batches of 100.\n3. **Telemetry**: During each batch, the server calculates:\n * **Accuracy**: Based on the `lightgbm` supervised model prediction.\n * **Statistics**: Tracks actual vs. predicted counts for classes.\n * **Latencies**: Tracks individual model performance (Autoencoder, Isolation Forest, FFNN, LightGBM, LogReg, XGBoost) and the total pipeline latency.\n4. **Streaming**: It sends a `batch` message containing the results and current stats, followed by a `summary` message once the stream is complete.\n\n#### Example Initialization Message:\n```json\n{\n \"command\": \"start\",\n \"token\": \"your_secure_token_here\",\n \"start_at\": 0\n}\n```\n\n#### Example Summary Message:\nAt the end of the stream, the server sends:\n```json\n{\n \"type\": \"summary\",\n \"status\": \"Stream Complete\",\n \"statistics\": {\n \"accuracy\": 0.85,\n \"total_processed\": 1000,\n \"correct_predictions\": 850,\n \"actual_counts\": {\"0\": 100, \"1\": 750},\n \"predicted_counts\": {\"0\": 120, \"1\": 730},\n \"average_latencies\": {\n \"autoencoder\": 0.000123,\n \"isolation_forest\": 0.000045,\n \"ffnn\": 0.000456,\n \"lightgbm\": 0.000789,\n \"logreg\": 0.000012,\n \"xgboost\": 0.000890,\n \"pipeline\": 0.002000\n }\n }\n}\n```\n\nYou can find the full implementation logic in `knowledge_base\\repos\\IntrusionBackend\\router.py` and the API documentation in `knowledge_base\\repos\\IntrusionBackend\\documentation.md`.",
"Based on the `CaptchaOCR` repository, you have a complete, working PyTorch training pipeline already implemented.\n\n### How to use your existing pipeline:\n\n1. **Environment Setup**: Ensure your environment is configured with the necessary dependencies:\n ```bash\n # Install PyTorch with CUDA support\n pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu128\n\n # Install other dependencies\n pip install captcha pandas pillow\n ```\n\n2. **Generate Dataset**: If you haven't generated the synthetic data yet, run the data generation script located in the `src` directory:\n ```bash\n cd src\n python data.py\n ```\n This will create 10,000 synthetic CAPTCHAs in `Dataset_test/captchas/` with the required train/val/test splits.\n\n3. **Run Training**: Execute the main training script:\n ```bash\n python train.py\n ```\n\n### Pipeline Features:\nYour current pipeline includes:\n* **Automatic Metrics**: Training/validation loss tracking and automatic plot generation in the `Metrics/` folder.\n* **Early Stopping**: An enhanced early stopping mechanism is implemented to prevent overfitting.\n* **Logging**: Comprehensive logging of logits, predictions, and model health.\n* **Model Architecture**: A CRNN (CNN encoder + BiLSTM + LayerNorm + linear output) that is confirmed to be working with correct output shapes.\n* **Data Handling**: A custom PyTorch `Dataset` class, CTC collate function for variable-length sequences, and a vocabulary system for character encoding/decoding.\n\nYou can find the source code for these components in the `src/` directory (e.g., `train.py`, `model_crnn.py`, `captcha_dataset.py`, `collate.py`).",
"The allowed origins for your **IntrusionBackend** project are defined in `knowledge_base\\repos\\IntrusionBackend\\cors.py` within the `configure_cors` function. They are:\n\n* `https://mohakapoor.in`\n* `https://sisyphus.mohakapoor.in`\n* `http://mohakapoor.in`\n* `http://sisyphus.mohakapoor.in`\n* `http://localhost:8000`",
"CORS origins are configured in the `cors.py` file within the `IntrusionBackend` repository. Specifically, the `configure_cors` function defines the `allowed_origins` list.\n\nThe following origins are currently configured:\n* `https://mohakapoor.in`\n* `https://sisyphus.mohakapoor.in`\n* `http://mohakapoor.in`\n* `http://sisyphus.mohakapoor.in`\n* `http://localhost:8000`",
"Based on the provided documentation for the **IntrusionBackend** project, environment variables are loaded from a `.env` file.\n\nAccording to `knowledge_base\\repos\\IntrusionBackend\\README.md` and `knowledge_base\\repos\\IntrusionBackend\\documentation.md`, you should create a `.env` file in your project root containing the following keys:\n\n* `TOKEN`\n* `PATH_LIGHTGBM`\n* `PATH_XGBOOST`\n* `PATH_PCA`\n* `PATH_STANDARD`\n* `PATH_MINMAX`\n\nYou can initialize this file by running `cp .env.example .env` in your terminal.",
"The Docker configuration for the **IntrusionBackend** is located in the file `knowledge_base/repos/IntrusionBackend/docker-compose.yml`.\n\nAdditionally, the `README.md` file in the same repository provides instructions on how to use this configuration to run the project:\n\n1. **Build and Run**: You can start the service using the command `docker-compose up --build`.\n2. **Environment Variables**: The `docker-compose.yml` file is configured to use an `.env` file for environment variables.",
"Based on the provided codebase context, there is no information regarding the definition or configuration of GitHub Actions. The repositories (`CaptchaOCR`, `HermesGPT`, and `IntrusionBackend`) do not contain any `.github` directory or workflow files in their file structures.",
"Based on the provided codebase, the configuration for preprocessing and scaling depends on which repository you are referring to:\n\n### **IntrusionBackend**\nIn the `IntrusionBackend` repository, data preprocessing and scaling logic is centralized in **`utils.py`**. According to the documentation:\n* **`utils.py`**: Handles data loading (using Polars), scaling (MinMax/Standard), and preprocessing.\n* **`scalers/`**: This directory contains the serialized transformation models used for data normalization (e.g., PCA, Scalers).\n\nIn the inference logic (`predict.py`), the functions `predict_attack` and `predict_attack_by_idx` explicitly call:\n* `scale_unsupervised(raw_sample)` for unsupervised models.\n* `scale_supervised(raw_sample)` for supervised models.\n\n### **CaptchaOCR**\nIn the `CaptchaOCR` repository, image preprocessing is handled differently:\n* **`inference.py`**: The `main()` function calls `preprocess_image(image_path)` before running the model prediction.\n* **Development Workflow**: The `README.md` notes that \"Implement Dataset class\" (which includes loading and preprocessing images) is the first step of the development workflow.\n\nIf you are looking for specific configuration parameters (like scaling factors or image dimensions), you should check the `config` files or the specific implementation of the `preprocess` functions within those files.",
"Based on the provided codebase, there is no explicit code implementation for email rate limits (such as a specific rate-limiting library or logic to enforce a maximum number of emails per hour/day).\n\nHowever, the **README.md** file mentions the following in the **Features** section:\n\n* **Batch Processing**: \"Sends emails in batches with randomized delays to prevent spam detection.\"\n\nWhile the code for `get_recruiters` in `hermesgpt.py` (lines 54-71) supports a `batch_size` parameter (defaulting to 40), the actual logic for the \"randomized delays\" mentioned in the README is not present in the provided snippets.",
"Based on the provided codebase, the inference process in your project works as follows:\n\n### **How to Run Inference**\nYou can run the inference pipeline by executing the `inference.py` script:\n```bash\npython inference.py\n```\nAccording to the `README.md`, this script performs the following tasks:\n* **Automatic Model Loading:** It automatically loads the best trained model.\n* **Evaluation:** It generates fresh test CAPTCHAs to evaluate the model.\n* **Metrics:** It calculates and displays both overall and character-level accuracy.\n* **Visualization:** It creates visualization plots and saves them in the `Metrics` folder.\n\n### **Technical Implementation**\nThe core logic for running inference on a single image is handled by the `predict_captcha` function in `inference.py`:\n1. **Device Preparation:** The input `image_tensor` is moved to the appropriate device (CPU or GPU).\n2. **Forward Pass:** The model processes the tensor to produce `logits`.\n3. **Decoding:** The `logits` are passed through `ctc_greedy_decode` to convert the model output into a readable string.\n\n### **Integration**\nThe project also includes a Gradio-based web interface (`app.py`) that utilizes the inference pipeline. It initializes the model using `inf.load_model(\"checkpoints/best_model.pth\")` and sets it to evaluation mode (`.eval()`) to provide a user-friendly way to test the CAPTCHA recognition.\n\n### **Performance**\nThe current inference pipeline is highly effective, achieving:\n* **75-100% overall accuracy** on fresh CAPTCHAs.\n* **96%+ character accuracy** (correctly identifying 25 out of 26+ characters).",
"In your project, the WebSocket streaming functionality is handled by the `websocket_stream` function located in `router.py`. It is designed to stream datasets in batches of 100 rows while providing real-time telemetry.\n\nHere is how the process works:\n\n### 1. Connection and Authentication\n* **Endpoint**: You connect via `WS /intrusiondetection/ws/stream`.\n* **Initialization**: Upon connecting, the client must send a JSON message containing a `command` (\"start\"), a `token` for authentication, and an optional `start_at` index.\n* **Validation**: The server verifies the provided token against the `API_TOKEN` before proceeding.\n\n### 2. Batch Processing\n* **Execution**: The server iterates through the dataset in batches of 100 rows.\n* **Inference**: For each row, the server calls `predict.predict_attack_by_idx` using an executor to perform inference across your hierarchical ML pipeline (Autoencoders, Isolation Forests, LightGBM, XGBoost, etc.).\n* **Real-time Stats**: During processing, the server tracks:\n * **Accuracy**: Calculated based on the `LightGBM` prediction compared to the actual target class.\n * **Counts**: Tracks actual vs. predicted class distributions.\n * **Latencies**: Measures the time taken for each individual model and the total pipeline latency.\n\n### 3. Communication\n* **Batch Updates**: After each batch of 100 rows, the server sends a JSON message to the client containing the batch data, the current `accuracy`, and the number of processed rows.\n* **Summary**: Once the entire dataset is processed, the server sends a final `summary` message. This includes the final accuracy, total counts, and the average latency for every model in your pipeline.\n* **Termination**: The connection is closed automatically by the server once the stream is complete (code 1000).\n\n### 4. Implementation Details\n* **File**: `router.py` (lines 191\u2013315).\n* **Dependencies**: It relies on `predict.py` for model inference and `utils.py` for data handling.\n* **Configuration**: The WebSocket logic is part of your FastAPI application, which also includes secure CORS policies and token-based authentication to ensure the stream is protected.",
"Based on the provided codebase, the process of an image traveling from \"upload\" (or generation) to prediction follows these steps:\n\n### 1. Image Acquisition\nIn your project, images are typically generated for testing or provided via an internal path.\n* **Generation:** In `inference.py` (within the `main` function), the `generate_test_captcha` function creates an image and returns its file path.\n* **UI Interaction:** In `app.py`, the `ui_generate` function (triggered by the \"Generate CAPTCHA\" button) creates an image and provides an internal path to the `path_box` component.\n\n### 2. Preprocessing\nOnce an image path is available, it must be converted into a format the model can process. This is handled by the `preprocess_image` function in `inference.py`:\n* **Loading:** The image is read using `cv2.imread` (either in grayscale or color based on `cfg.grayscale`).\n* **Resizing:** It is resized to `(cfg.W_max, cfg.H)`.\n* **Normalization:** The pixel values are converted to a float tensor and normalized by dividing by 255.0.\n* **Dimension Adjustment:** The tensor is reshaped to include batch and channel dimensions (e.g., `[1, 1, H, W]` for grayscale or `[1, 3, H, W]` for color) using `unsqueeze` and `permute`.\n\n### 3. Inference (Prediction)\nThe preprocessed tensor is then passed to the `predict_captcha` function in `inference.py`:\n* **Device Transfer:** The tensor is moved to the appropriate device (CPU or GPU) using `.to(device)`.\n* **Forward Pass:** The model performs a forward pass on the tensor to generate `logits`.\n* **Decoding:** The `logits` are passed to `ctc_greedy_decode` to convert the model's output into a readable string.\n\n### 4. Result Handling\n* **In `inference.py`:** The `main` function compares the returned prediction against the target text to calculate accuracy and optionally generates a visualization using `TrainingMetrics.plot_results`.\n* **In `app.py`:** The `ui_solve` function (triggered by the \"Solve\" button) takes the internal path, runs the preprocessing and prediction pipeline, and updates the UI components (`accuracy_out` and `pred_out`) with the results.",
"Based on the provided codebase, WebSocket clients are managed through the `websocket_stream` function located in `router.py`. Here is how the management process works:\n\n1. **Connection and Authentication**:\n * The client connects to the endpoint `WS /intrusiondetection/ws/stream`.\n * Upon connection, the server calls `await websocket.accept()`.\n * The client must send an initialization JSON message containing a `command` (\"start\") and a `token`.\n * The server validates the provided token against `API_TOKEN`. If the token is invalid, it sends an \"Unauthorized\" error, closes the connection with code `1008`, and terminates the function.\n\n2. **Streaming Process**:\n * Once authenticated, the server processes the dataset in batches of 100 rows.\n * It uses `asyncio.get_event_loop()` and `run_in_executor` to perform model inference (`predict.predict_attack_by_idx`) without blocking the event loop.\n * Real-time statistics (accuracy, counts, and latencies) are tracked throughout the stream.\n * The server sends batch updates to the client via `await websocket.send_json(...)`.\n * An `await asyncio.sleep(0.01)` is included between batches to manage flow control.\n\n3. **Completion and Error Handling**:\n * **Completion**: Once the entire dataset is processed, the server sends a final summary message containing the aggregated statistics and average latencies, then closes the connection with code `1000`.\n * **Disconnection**: The code explicitly catches `WebSocketDisconnect` to handle cases where the client disconnects prematurely.\n * **Errors**: Any other exceptions are caught, logged, and the connection is closed with code `1011`.\n\nThis logic is defined in `router.py` (lines 191\u2013315).",
"The training pipeline for **CaptchaOCR** is designed as an end-to-end system using PyTorch. Based on the provided documentation, here is how the pipeline functions:\n\n### 1. Data Preparation\n* **Synthetic Generation**: You generate training data using `src/data.py`, which creates 10,000 synthetic CAPTCHA images stored in `Dataset_test/captchas/` with predefined train, validation, and test splits (8k train, 1k val).\n* **Preprocessing**: The `PyTorch Dataset` class handles image loading and preprocessing, including resizing using `cv2`.\n* **Batching**: The pipeline utilizes a custom **CTC Collate Function** to handle the batching of variable-length sequences.\n\n### 2. Model Architecture\n* The system uses a **CRNN (Convolutional Recurrent Neural Network)** architecture consisting of:\n * **CNN Encoder**: Extracts features from the CAPTCHA images.\n * **BiLSTM**: Processes the sequence features.\n * **LayerNorm & Linear Output**: Produces the final character predictions.\n* The model is configured to output a shape of `64 \u00d7 batch \u00d7 63`, where 63 represents the vocabulary size (including the CTC blank token).\n\n### 3. Training Execution\n* **Training Loop**: You initiate the process by running `python train.py`.\n* **Loss Function**: The pipeline uses **CTC (Connectionist Temporal Classification) loss**, which is standard for sequence recognition tasks where the alignment between input and output is unknown.\n* **Optimization & Monitoring**:\n * The pipeline includes **Early Stopping** to prevent overfitting.\n * It provides real-time monitoring of loss and prediction samples.\n * It automatically generates training/validation loss visualizations in the `Metrics/` folder.\n * Comprehensive logs and model health checks (logits, predictions) are generated during the process.\n\n### 4. Current Status\nAccording to the `README.md`, the training pipeline is currently stable with excellent loss convergence. As of the latest report, the model has achieved a validation loss of 0.1782 and is performing at 75\u2013100% accuracy on fresh CAPTCHAs.",
"Based on the provided codebase context, there is no mention of any Rust projects.\n\nThe repositories identified in the context are:\n* **HermesGPT** (License: MIT)\n* **IntrusionBackend** (Uses Python libraries such as `fastapi`, `pandas`, `scikit-learn`, `lightgbm`, `xgboost`, `torch`, etc., as listed in `requirements.txt`)\n* **CaptchaOCR** (Educational project referencing CTC and CRNN papers)\n\nThe information regarding a Rust project is unavailable.",
"Based on the provided codebase context, there is no mention of Kubernetes.\n\nThe **IntrusionBackend** repository notes that it is \"Containerized: Ready for deployment via Docker and Docker Compose,\" but it does not specify the use of Kubernetes. The other repositories (**HermesGPT** and **CaptchaOCR**) do not contain information regarding their deployment infrastructure.",
"Based on the provided codebase context, there is no mention of **Redis Streams**.\n\nThe project utilizes **WebSocket streaming** for processing and evaluating datasets, as defined in `knowledge_base\\repos\\IntrusionBackend\\router.py` and documented in `knowledge_base\\repos\\IntrusionBackend\\documentation.md`. The implementation handles data in batches of 100 rows directly from the dataset (e.g., `unscaled_test.parquet`) and streams the results and statistics to the client via the `WS /intrusiondetection/ws/stream` endpoint.",
"Based on the provided codebase context, there is no mention of GraphQL in any of the repositories (IntrusionBackend, HermesGPT, or CaptchaOCR). Therefore, it appears you have not implemented GraphQL in these projects.",
"Based on the provided context, the repository **IntrusionBackend** uses FastAPI.\n\nThis is confirmed by:\n* **`knowledge_base\\repos\\IntrusionBackend\\cors.py`**: Imports `FastAPI` from `fastapi`.\n* **`knowledge_base\\repos\\IntrusionBackend\\router.py`**: Initializes the application with `app = FastAPI(title=\"Intrusion Detection API\", version=\"1.0.0\")`.\n* **`knowledge_base/repos/IntrusionBackend/manifest.json`**: Lists \"fastapi\" as one of the topics for the repository.\n* **`knowledge_base\\repos\\IntrusionBackend\\documentation.md`**: States that the system is powered by FastAPI.",
"Based on the provided codebase context, the project that uses Gemini is **HermesGPT**.\n\nAccording to `knowledge_base\\repos\\HermesGPT\\hermesgpt.py` (lines 88-89), the project configures the Google Generative AI SDK and initializes a chat session using the `gemini-2.0-flash` model. Additionally, the `README.md` for HermesGPT confirms that it uses Gemini AI to generate tailored cold emails.",
"Based on the provided codebase context, the following projects use PyTorch:\n\n* **CaptchaOCR**: This project uses PyTorch with CUDA support for its CRNN (CNN + RNN) architecture and CTC-based sequence modeling (found in `knowledge_base\\repos\\CaptchaOCR\\README.md`).\n* **IntrusionBackend**: This project lists PyTorch as part of its ML/DL tech stack (found in `knowledge_base\\repos\\IntrusionBackend\\README.md`).",
"Based on the provided codebase, the following project exposes a REST API:\n\n* **IntrusionBackend**: The file `knowledge_base\\repos\\IntrusionBackend\\router.py` contains an endpoint `api_name` that returns `{\"api_name\": \"Intrusion Detection API\"}`.\n\nThe provided context for **HermesGPT** does not explicitly mention a REST API; it describes setup instructions involving the Gmail API, Gemini AI API, and database configuration.",
"The `generate_captcha` function is defined in `src/generateCaptcha.py`. It is responsible for creating enhanced CAPTCHA images with various effects like rotation, perspective warping, interference, noise, and blur.\n\n### Function Signature\n```python\ndef generate_captcha(text=None, width=IMG_WIDTH, height=IMG_HEIGHT, save_path=None)\n```\n\n### Key Details:\n* **Parameters:**\n * `text` (str, optional): The text to render. If `None`, it generates a random string of length 5\u20137 characters.\n * `width` (int): Image width (defaults to `IMG_WIDTH` = 256).\n * `height` (int): Image height (defaults to `IMG_HEIGHT` = 60).\n * `save_path` (str, optional): If provided, the image is saved to this path and the path is returned. If `None`, a PIL Image object is returned.\n* **Functionality:**\n * It uses `captcha.image.ImageCaptcha` for base rendering.\n * It applies several enhancements: random background (solid or gradient), rotation, perspective warping, interference lines/dots, noise, blur, and JPEG recompression.\n * It supports a `GRAYSCALE` configuration (defaulting to `True` in `src/generateCaptcha.py`).\n\n### Usage Examples in the Codebase:\n* **In `app.py` (`ui_generate` function):**\n ```python\n img = generate_captcha(text, width=cfg.W_max, height=cfg.H)\n ```\n* **In `inference.py` (`generate_test_captcha` function):**\n ```python\n img = generate_captcha(text, width=width, height=height)\n ```\n* **Direct usage in `src/generateCaptcha.py`:**\n ```python\n img1 = generate_captcha(\"HELLO\", save_path=\"sample_HELLO.png\")\n ```",
"Based on the provided codebase, here is how the CAPTCHA dataset generation is handled:\n\n### Overview\nThe project uses synthetic CAPTCHA generation to create training data. The generation process is managed within the `src` directory.\n\n### How to Generate the Dataset\nAccording to the `README.md` file, you can generate the training dataset by following these steps:\n1. Navigate to the `src` directory: `cd src`\n2. Run the data generation script: `python data.py`\n\nThis process creates **10,000 synthetic CAPTCHAs** stored in the `Dataset_test/captchas/` directory, which includes the necessary train/val/test splits.\n\n### Technical Details\n* **Generation Logic:** The project utilizes a utility for synthetic CAPTCHA generation. The configuration for these images (such as dimensions and character sets) is defined in `knowledge_base\\repos\\CaptchaOCR\\src\\generateCaptcha.py`.\n * **Image Dimensions:** Default width is 256 and height is 60.\n * **Character Set:** Uses `string.ascii_letters + string.digits`.\n * **Length:** CAPTCHA strings are generated with a length between 5 and 7 characters.\n* **Testing:** There is also a `generate_test_captcha` function in `inference.py` that allows for generating individual test CAPTCHA images using the same enhanced generation logic.\n* **Dependencies:** The generation process relies on libraries such as `captcha`, `pandas`, and `pillow` (as noted in the `README.md` setup instructions).",
"Based on the provided codebase, there is no single function named `predict_intrusion`. However, the system provides several endpoints and functions for performing intrusion detection predictions:\n\n### 1. API Endpoints (Public/Protected)\nAccording to `knowledge_base\\repos\\IntrusionBackend\\documentation.md`, the following endpoints are available for predictions:\n\n* **Hybrid Detection (Recommended):** `POST /intrusiondetection/predict/hybrid`\n * Uses a hierarchical pipeline: Anomaly detection (Unsupervised) followed by Classification (Supervised). LightGBM acts as the final \"Veto.\"\n* **Prediction By Index:** `POST /intrusiondetection/predict/hybrid_by_index`\n * Uses the `unscaled_test.parquet` dataset.\n* **Direct Model Endpoints:**\n * `POST /predict/logreg`\n * `POST /predict/lightgbm`\n * `POST /predict/ffnn`\n\n### 2. Backend Implementation\n* **`predict_hybrid_by_index_endpoint`** (in `router.py`): This endpoint calls `predict.predict_attack_by_idx(data.index)` to perform the hybrid prediction.\n* **`predict_isolation_forest_endpoint`** (in `router.py`): This endpoint uses `predict._predict_isolation_forest(raw_sample)` to perform an isolation forest prediction.\n* **`generate_stats`** (in `stats.py`): This function iterates through the dataset and calls `predict.predict_attack_by_idx(idx)` to evaluate the model performance and generate reports (confusion matrix and classification report).\n\nIf you are looking to implement or call a prediction, you should refer to the `predict` module or use the endpoints defined in `router.py`.",
"**HermesGPT** is an intelligent automation tool designed to streamline the process of reaching out to recruiters for internship opportunities.\n\n### Key Features\n* **AI-Generated Emails:** Uses Gemini AI to create personalized cold emails.\n* **Database Management:** Tracks recruiter information and contact status using PostgreSQL.\n* **Email Automation:** Integrates with the Gmail API for automated sending.\n* **Verification:** Includes email verification capabilities.\n\n### Project Structure\nAccording to the `portfolio_graph`, the repository contains the following files:\n* `hermesgpt.py`: Contains the core logic, including the `connect_db` function.\n* `manifest.json`: Metadata for the repository.\n* `README.md`: Setup and usage instructions.\n* `requirements.txt`: Project dependencies.\n\n### Database Configuration\nThe project uses PostgreSQL. The `connect_db` function in `hermesgpt.py` is configured with the following defaults:\n* **Database Name:** `hermesgpt`\n* **User:** `postgres`\n* **Password:** `1234`\n* **Host:** `localhost`\n* **Port:** `5432`\n\nThe required schema for the `recruiters` table is:\n```sql\nCREATE TABLE recruiters (\nemail TEXT PRIMARY KEY,\nrecruiter_name TEXT,\ncompany_name TEXT,\nrole TEXT,\ncontacted BOOLEAN DEFAULT FALSE\n);\n```\n\n### Getting Started\n1. **Clone the repo:** `git clone https://github.com/your-username/HermesGPT.git`\n2. **Install dependencies:** `pip install -r requirements.txt`\n3. **Setup:** Configure your PostgreSQL database, place your `credentials.json` (for Gmail API) in the root directory, and add your Gemini AI API key to the `API_KEY` variable.\n4. **Data:** Prepare a `recruiters.csv` file with the columns: Email, Name, Company, and Title."
],
"contexts": [
[
{
"text": "### \u2705 Completed Components\n- **Dataset Generation**: Synthetic CAPTCHA creation with train/val/test splits (8k train, 1k val)\n- **Configuration**: Centralized config with image dimensions and training parameters\n- **Vocabulary System**: Character encoding/decoding with CTC blank token support (63 classes)\n- **CTC Collate Function**: Proper batching for variable-length sequences\n- **CTC Decoding**: Greedy decode for inference\n- **PyTorch Dataset Class**: Image loading and preprocessing with proper cv2 resizing\n- **CRNN Model**: CNN encoder + BiLSTM + LayerNorm + linear output (working!)\n- **Training Loop**: Complete epoch-based training pipeline with validation\n- **Metrics & Plotting**: Training/validation loss tracking with beautiful visualizations\n- **Debugging Tools**: Comprehensive logging of logits, predictions, and model health \n### \u2705 What's Working\n- **Training Pipeline**: Stable training loop with excellent loss convergence",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83c\udfd7\ufe0f Current Status",
"symbol": "\ud83c\udfd7\ufe0f Current Status",
"chunk_idx": 3,
"size": 945,
"_id": "cc52b2b4-6738-5973-9c50-29fc8882ca66",
"_collection_name": "code_atlas"
}
},
{
"text": "This project implements an end-to-end CAPTCHA OCR system that can recognize text in CAPTCHA images. It uses:\n- **Synthetic CAPTCHA generation** for training data\n- **CRNN (CNN + RNN) architecture** for sequence recognition\n- **CTC (Connectionist Temporal Classification)** loss for training\n- **PyTorch** with CUDA support for GPU acceleration",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83c\udfaf Project Overview",
"symbol": "\ud83c\udfaf Project Overview",
"chunk_idx": 2,
"size": 343,
"_id": "43771423-20e5-54f3-a5d2-86f6a9285d92",
"_collection_name": "code_atlas"
}
},
{
"text": "### 1. Environment Setup\n```bash\n# Install PyTorch with CUDA support (adjust version as needed)\npip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu128\n\n# Install other dependencies\npip install captcha pandas pillow\n``` \n### 2. Generate Training Dataset\n```bash\ncd src\npython data.py\n```\nThis creates 10,000 synthetic CAPTCHAs in `Dataset_test/captchas/` with proper train/val/test splits. \n### 3. Start Training\n```bash\npython train.py\n```\nThis starts the full training pipeline with automatic metrics generation. \n### 4. Monitor Progress\nTraining will show:\n- Real-time loss and prediction samples\n- Automatic plot generation in `Metrics/` folder\n- Comprehensive training logs and summaries",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83d\ude80 Quick Start",
"symbol": "\ud83d\ude80 Quick Start",
"chunk_idx": 7,
"size": 721,
"_id": "3b357f42-2155-5453-a29c-795d0e1c9c09",
"_collection_name": "code_atlas"
}
},
{
"text": "A PyTorch-based CAPTCHA recognition system using synthetic data generation and CTC-based sequence modeling. Built with deep learning techniques, achieving high accuracy on complex text recognition tasks.",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "None",
"symbol": "CAPTCHA OCR Project",
"chunk_idx": 1,
"size": 203,
"_id": "89c221f0-2ced-5f9a-9c1d-e200c57f37f5",
"_collection_name": "code_atlas"
}
},
{
"text": "```\nCaptchaDetect/\n\u251c\u2500\u2500 Dataset/ # Full dataset (100k images) - for Colab training\n\u251c\u2500\u2500 Dataset_test/ # Test dataset (1k images) - for local development\n\u2502 \u2514\u2500\u2500 captchas/\n\u2502 \u251c\u2500\u2500 train/ # 80% of data\n\u2502 \u251c\u2500\u2500 val/ # 10% of data\n\u2502 \u2514\u2500\u2500 test/ # 10% of data\n\u251c\u2500\u2500 src/\n\u2502 \u251c\u2500\u2500 config.py # Configuration and hyperparameters\n\u2502 \u251c\u2500\u2500 vocab.py # Character vocabulary and CTC encoding/decoding\n\u2502 \u251c\u2500\u2500 data.py # Dataset generation script\n\u2502 \u251c\u2500\u2500 collate.py # CTC batching function\n\u2502 \u251c\u2500\u2500 captcha_dataset.py # PyTorch Dataset class\n\u2502 \u251c\u2500\u2500 model_crnn.py # CRNN model architecture\n\u2502 \u2514\u2500\u2500 plotting.py # Training metrics and visualization\n\u251c\u2500\u2500 train.py # Main training script (\u2705 WORKING!)\n\u251c\u2500\u2500 Metrics/ # Training plots and logs (auto-generated)\n\u251c\u2500\u2500 .gitignore # Ignores dataset contents, keeps structure\n\u2514\u2500\u2500 README.md # This file\n```",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83d\udcc1 Project Structure",
"symbol": "\ud83d\udcc1 Project Structure",
"chunk_idx": 6,
"size": 1000,
"_id": "c4ad4ab2-d4d1-52cc-ac79-15c6a80162c1",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "def generate_captcha(text=None, width=IMG_WIDTH, height=IMG_HEIGHT, save_path=None):\n \"\"\"\n Generate a single enhanced CAPTCHA image.\n \n Args:\n text (str, optional): Text to render. If None, generates random text.\n width (int): Image width\n height (int): Image height\n save_path (str, optional): Path to save the image. If None, returns PIL Image.\n \n Returns:\n PIL Image if save_path is None, otherwise saves and returns the path\n \"\"\"\n # Generate random text if none provided\n if text is None:\n text = ''.join(random.choices(CHARS, k=random.randint(CAPTCHA_LEN_LOWER_LIMIT, CAPTCHA_LEN_UPPER_LIMIT)))\n \n # Randomize basic style\n bg_choice = random.choice([\"solid\", \"gradient\"])\n fg_color = rand_color(0, 80)\n \n if bg_choice == \"solid\":\n bg_color = rand_color(210, 255)\n bg = Image.new(\"RGB\", (width, height), color=bg_color)\n else:\n bg = gradient_bg(width, height)\n\n # Adjust font sizes for larger dimensions\n font_sizes = [int(height * 0.7), int(height * 0.75), int(height * 0.8), int(height * 0.85)]\n font_size = random.choice(font_sizes)\n \n # Use ImageCaptcha for base text rendering\n from captcha.image import ImageCaptcha\n image = ImageCaptcha(width=width, height=height, fonts=None, font_sizes=[font_size])\n \n # Draw base image\n base = Image.frombytes('RGB', (width, height), image.generate_image(text).tobytes())\n\n # Apply enhancements\n angle = random.uniform(-6, 6)\n base = base.rotate(angle, resample=Image.BILINEAR, expand=False, fillcolor=bg.getpixel((0,0)))\n\n # Perspective warp (very light)\n if random.random() < 0.6:\n base = perspective_warp(base, max_ratio=0.025)\n\n # Add interference\n base = add_interference(base, line_range=(0, 3), dot_range=(10, 60))\n\n # Noise + blur + JPEG recompression\n base = add_noise_and_blur(base, noise_sigma=(0.0, 5.0), blur_sigma=(0.0, 0.7), motion_prob=0.12)\n base = jpeg_recompress(base, qmin=72, qmax=92)\n\n # Optional low contrast\n if random.random() < 0.2:\n base = base.point(lambda p: int(p*0.95 + 6))\n\n # Convert to grayscale if specified\n if GRAYSCALE:\n base = base.convert('L')\n \n # Save or return\n if save_path:\n base.save(save_path)\n return save_path\n else:\n return base",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\src\\generateCaptcha.py",
"filename": "generateCaptcha.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "function",
"start_line": 104,
"end_line": 170,
"symbol": "generate_captcha",
"chunk_idx": 7,
"size": 2362,
"_id": "5961a050-0f46-5993-aadb-d341153dadc1",
"_collection_name": "code_atlas"
}
},
{
"text": "def render_with_variation(text, width=IMG_WIDTH, height=IMG_HEIGHT):\n # randomize basic style knobs\n bg_choice = random.choice([\"solid\", \"gradient\"])\n fg_color = rand_color(0, 80)\n if bg_choice == \"solid\":\n bg_color = rand_color(210, 255)\n bg = Image.new(\"RGB\", (width, height), color=bg_color)\n else:\n bg = gradient_bg(width, height)\n\n # Adjust font sizes for larger dimensions\n font_sizes = [int(height * 0.7), int(height * 0.75), int(height * 0.8), int(height * 0.85)]\n font_size = random.choice(font_sizes)\n \n # ImageCaptcha accepts fonts via fonts arg; here we keep default but jitter spacing\n image = ImageCaptcha(width=width, height=height, fonts=None, font_sizes=[font_size])\n\n # draw base image\n base = Image.frombytes('RGB', (width, height), image.generate_image(text).tobytes())\n\n # quick contrast tweak: recolor foreground by compositing text mask if needed\n # For minimal change, we stick with base and apply light warps/noise\n # mild rotation/shear\n angle = random.uniform(-6, 6)\n base = base.rotate(angle, resample=Image.BILINEAR, expand=False, fillcolor=bg.getpixel((0,0)))\n\n # perspective warp (very light)\n if random.random() < 0.6:\n base = perspective_warp(base, max_ratio=0.025)\n\n # draw interference over the image\n base = add_interference(base, line_range=(0, 3), dot_range=(10, 60))\n\n # light noise + blur + jpeg recompress to add artifacts\n base = add_noise_and_blur(base, noise_sigma=(0.0, 5.0), blur_sigma=(0.0, 0.7), motion_prob=0.12)\n base = jpeg_recompress(base, qmin=72, qmax=92)\n\n # optional low contrast: 20% chance to darken bg and lighten fg a bit\n if random.random() < 0.2:\n base = base.point(lambda p: int(p*0.95 + 6))\n\n # Convert to grayscale if specified\n if GRAYSCALE:\n base = base.convert('L')\n \n return base",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\src\\data.py",
"filename": "data.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "function",
"start_line": 100,
"end_line": 145,
"symbol": "render_with_variation",
"chunk_idx": 7,
"size": 1883,
"_id": "edf9c02e-26d0-5908-ba80-89e641ae5441",
"_collection_name": "code_atlas"
}
},
{
"text": "1. **Implement Dataset class** - Load and preprocess images\n2. **Build CRNN model** - CNN + BiLSTM architecture\n3. **Create training loop** - With validation and checkpoints\n4. **Add metrics** - CER and accuracy tracking\n5. **Test on small dataset** - Verify everything works\n6. **Scale to full dataset** - Train on Colab",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83d\udee0\ufe0f Development Workflow",
"symbol": "\ud83d\udee0\ufe0f Development Workflow",
"chunk_idx": 15,
"size": 321,
"_id": "60bcb358-3110-5090-a80c-cf9343a2c6c2",
"_collection_name": "code_atlas"
}
},
{
"text": "This is a learning project! Feel free to:\n- Ask questions about implementation details\n- Experiment with different architectures\n- Improve the data generation or training pipeline",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83e\udd1d Contributing",
"symbol": "\ud83e\udd1d Contributing",
"chunk_idx": 16,
"size": 179,
"_id": "0bb57d4e-10c5-5bbe-83d6-74f9591fda94",
"_collection_name": "code_atlas"
}
},
{
"text": "def preprocess_image(image_path, target_size=(cfg.W_max, cfg.H)):\n \"\"\"Preprocess image for inference (same as training).\"\"\"\n # Load image\n if not os.path.exists(image_path):\n raise FileNotFoundError(f\"Image not found: {image_path}\")\n \n # Read and preprocess\n img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE if cfg.grayscale else cv2.IMREAD_COLOR)\n if img is None:\n raise ValueError(f\"Failed to load image: {image_path}\")\n \n # Resize to target dimensions\n img = cv2.resize(img, target_size)\n \n # Convert to tensor and normalize\n img_tensor = torch.from_numpy(img).float() / 255.0\n \n # Add batch and channel dimensions\n if cfg.grayscale:\n img_tensor = img_tensor.unsqueeze(0).unsqueeze(0) # [1, 1, H, W]\n else:\n img_tensor = img_tensor.permute(2, 0, 1).unsqueeze(0) # [1, 3, H, W]\n \n return img_tensor",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\inference.py",
"filename": "inference.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "function",
"start_line": 33,
"end_line": 56,
"symbol": "preprocess_image",
"chunk_idx": 2,
"size": 888,
"_id": "3d9a8566-e6a1-5788-985a-649fa1569bbc",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "This project implements an end-to-end CAPTCHA OCR system that can recognize text in CAPTCHA images. It uses:\n- **Synthetic CAPTCHA generation** for training data\n- **CRNN (CNN + RNN) architecture** for sequence recognition\n- **CTC (Connectionist Temporal Classification)** loss for training\n- **PyTorch** with CUDA support for GPU acceleration",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83c\udfaf Project Overview",
"symbol": "\ud83c\udfaf Project Overview",
"chunk_idx": 2,
"size": 343,
"_id": "43771423-20e5-54f3-a5d2-86f6a9285d92",
"_collection_name": "code_atlas"
}
},
{
"text": "with gr.Blocks(title=\"CAPTCHA OCR (checkpoint)\") as demo:\n gr.Markdown(\"## CAPTCHA OCR \")\n\n with gr.Row():\n # Left column: Generate button + Solve button stacked vertically\n with gr.Column(scale=1):\n gen_btn = gr.Button(\"Generate CAPTCHA\", variant=\"primary\")\n solve_btn = gr.Button(\"Solve\", interactive=False, variant=\"secondary\")\n \n # Right column: Ground Truth\n gt_out = gr.Textbox(label=\"Ground Truth\", interactive=False, text_align=\"center\")\n\n with gr.Row():\n img_out = gr.Image(label=\"Generated CAPTCHA\", type=\"pil\")\n path_box = gr.Textbox(label=\"Internal Path\", interactive=False, visible=False)\n\n # Prediction row split into two columns\n with gr.Row():\n accuracy_out = gr.Textbox(label=\"Character Accuracy\", interactive=False, text_align=\"center\")\n pred_out = gr.Textbox(label=\"Prediction\", interactive=False, text_align=\"center\")\n\n # Generate: outputs image, ground truth, path, and enables Solve (green)\n gen_btn.click(\n fn=ui_generate,\n outputs=[img_out, gt_out, path_box, solve_btn],\n )\n\n # Solve: only uses the internal path (no upload option anymore)\n solve_btn.click(\n fn=ui_solve,\n inputs=[path_box, gt_out],\n outputs=[accuracy_out, pred_out],\n )\nif __name__ == \"__main__\":\n demo.launch()",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\app.py",
"filename": "app.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "Module",
"start_line": 66,
"end_line": 101,
"symbol": "None",
"chunk_idx": 5,
"size": 1359,
"_id": "d33e2103-8a96-5c78-a5ce-4f9aff805aa9",
"_collection_name": "code_atlas"
}
},
{
"text": "import os\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import DataLoader\nfrom src.config import cfg\nfrom src.collate import ctc_collate\nfrom src.captcha_dataset import CaptchaDataset\nfrom src.vocab import vocab_size, ctc_greedy_decode\nfrom src.model_crnn import CRNN",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\train_sanity.py",
"filename": "train_sanity.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "Module",
"start_line": 1,
"end_line": 9,
"symbol": "None",
"chunk_idx": 0,
"size": 278,
"_id": "3d494ab3-9ece-5ec7-9d22-6f8d053ba66e",
"_collection_name": "code_atlas"
}
},
{
"text": "CAPTCHA OCR Training Metrics\n==================================================\n\nTraining completed at: 2025-08-20 02:25:00\nTotal epochs: 22\n\nLoss Summary:\n--------------------\nFinal training loss: 0.0146\nFinal validation loss: 0.0460\nBest training loss: 0.0146\nBest validation loss: 0.0460\nTraining loss improvement: 6.8262\nValidation loss improvement: 3.6347\n\nSample Predictions:\n--------------------\nSample 1: Predicted='N', Target='XjlCAhL'\nSample 2: Predicted='Mw', Target='I4Mwfs6'\nSample 3: Predicted='V', Target='CqHY4s'\nSample 4: Predicted='g', Target='dI3F6'\nSample 5: Predicted='HqU', Target='n0tfU'\nSample 6: Predicted='jxjlCAhL', Target='XjlCAhL'\nSample 7: Predicted='l4Mwfs6', Target='I4Mwfs6'\nSample 8: Predicted='CqHY4s', Target='CqHY4s'\nSample 9: Predicted='dI3F6', Target='dI3F6'\nSample 10: Predicted='n0tU', Target='n0tfU'\n",
"metadata": {
"repo": "CaptchaOCR",
"path": "knowledge_base/repos/CaptchaOCR/Metrics/training_metrics.txt",
"filename": "training_metrics.txt",
"language": "text",
"type": "text",
"chunk_idx": 0,
"size": 842,
"_id": "c58b990f-7efc-500a-84aa-496026e39763",
"_collection_name": "code_atlas"
}
},
{
"text": "- \ud83d\udcc4 **Resume Parsing**: Loads and processes resume data for personalized email generation.\n- \ud83e\udd16 **AI-Powered Emails**: Uses Gemini AI to generate tailored cold emails.\n- \ud83d\udcec **Automated Email Sending**: Sends emails via Gmail API with attachments.\n- \u2705 **Email Verification**: Uses SMTP and Maileroo API to validate emails before sending.\n- \ud83d\uddc4 **Database Management**: Stores recruiter data in PostgreSQL and tracks outreach progress.\n- \ud83d\udd04 **Batch Processing**: Sends emails in batches with randomized delays to prevent spam detection.",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "Features",
"symbol": "Features",
"chunk_idx": 1,
"size": 529,
"_id": "2b1ec077-3dbf-5a35-8275-b58b0b6597fd",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "def ctc_collate(batch: List[Tuple[torch.Tensor, str, str]]):\n \"\"\"\n batch: list of (image_tensor [C,H,W_max], label_str, rel_path)\n returns:\n images: [B,C,H,W_max]\n targets_flat: [sum(len(label_i))]\n target_lengths: [B]\n input_lengths: [B] (all equal if same W_max/stride)\n rel_paths: list[str]\n \"\"\"\n\n images = torch.stack([item[0] for item in batch],dim =0)\n\n labels = [item[1] for item in batch]\n encoded = [torch.tensor(encode_text(t),dtype = torch.long) for t in labels]\n target_lengths = torch.tensor([len(t) for t in encoded],dtype = torch.long)\n if len(encoded) > 0:\n targets_flat = torch.cat(encoded,dim = 0)\n else:\n targets_flat = torch.empty(0,dtype = torch.long)\n\n \n B, C, H, W = images.shape\n \n input_len = W // cfg.total_stride\n input_lengths = torch.full((B,), input_len, dtype=torch.long)\n\n rel_paths = [item[2] for item in batch]\n return images, targets_flat, target_lengths, input_lengths, rel_paths ",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\src\\collate.py",
"filename": "collate.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "function",
"start_line": 6,
"end_line": 34,
"symbol": "ctc_collate",
"chunk_idx": 1,
"size": 1010,
"_id": "d64dc2bc-d637-5702-b166-478f852d2aa7",
"_collection_name": "code_atlas"
}
},
{
"text": "- **Decoding**: Greedy CTC decode with duplicate removal \n### Data Pipeline\n- **Images**: Grayscale, normalized to [0,1], proper cv2 resizing\n- **Labels**: CSV with filename and text label\n- **Batching**: Variable-length sequences with custom CTC collate function\n- **Debugging**: Real-time monitoring of logits, blank probability, predictions",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83d\udd2c Technical Details",
"symbol": "\ud83d\udd2c Technical Details",
"chunk_idx": 13,
"size": 344,
"_id": "e2a53fc3-9830-52b8-aaf9-fca6ba1baef7",
"_collection_name": "code_atlas"
}
},
{
"text": "import os\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import DataLoader\nfrom src.config import cfg\nfrom src.collate import ctc_collate\nfrom src.captcha_dataset import CaptchaDataset\nfrom src.vocab import vocab_size, ctc_greedy_decode\nfrom src.model_crnn import CRNN",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\train_sanity.py",
"filename": "train_sanity.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "Module",
"start_line": 1,
"end_line": 9,
"symbol": "None",
"chunk_idx": 0,
"size": 278,
"_id": "3d494ab3-9ece-5ec7-9d22-6f8d053ba66e",
"_collection_name": "code_atlas"
}
},
{
"text": "import os\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import DataLoader\nfrom src.config import cfg\nfrom src.collate import ctc_collate\nfrom src.captcha_dataset import CaptchaDataset\nfrom src.vocab import vocab_size, ctc_greedy_decode, decode_indices, itos\nfrom src.plotting import TrainingMetrics\nfrom src.model_crnn import CRNN\nimport difflib",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\train.py",
"filename": "train.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "Module",
"start_line": 1,
"end_line": 11,
"symbol": "None",
"chunk_idx": 0,
"size": 356,
"_id": "307f7cee-e92d-5c12-beea-d71623f57153",
"_collection_name": "code_atlas"
}
},
{
"text": "### \u2705 Completed Components\n- **Dataset Generation**: Synthetic CAPTCHA creation with train/val/test splits (8k train, 1k val)\n- **Configuration**: Centralized config with image dimensions and training parameters\n- **Vocabulary System**: Character encoding/decoding with CTC blank token support (63 classes)\n- **CTC Collate Function**: Proper batching for variable-length sequences\n- **CTC Decoding**: Greedy decode for inference\n- **PyTorch Dataset Class**: Image loading and preprocessing with proper cv2 resizing\n- **CRNN Model**: CNN encoder + BiLSTM + LayerNorm + linear output (working!)\n- **Training Loop**: Complete epoch-based training pipeline with validation\n- **Metrics & Plotting**: Training/validation loss tracking with beautiful visualizations\n- **Debugging Tools**: Comprehensive logging of logits, predictions, and model health \n### \u2705 What's Working\n- **Training Pipeline**: Stable training loop with excellent loss convergence",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83c\udfd7\ufe0f Current Status",
"symbol": "\ud83c\udfd7\ufe0f Current Status",
"chunk_idx": 3,
"size": 945,
"_id": "cc52b2b4-6738-5973-9c50-29fc8882ca66",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "genai.configure(api_key=API_KEY)\nchat = genai.GenerativeModel('gemini-2.0-flash').start_chat(history=[])",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\hermesgpt.py",
"filename": "hermesgpt.py",
"repo": "HermesGPT",
"language": "python",
"type": "Module",
"start_line": 88,
"end_line": 89,
"symbol": "None",
"chunk_idx": 5,
"size": 104,
"_id": "1154c6b9-d133-500d-a3f6-38dd38fc41c8",
"_collection_name": "code_atlas"
}
},
{
"text": "- \ud83d\udcc4 **Resume Parsing**: Loads and processes resume data for personalized email generation.\n- \ud83e\udd16 **AI-Powered Emails**: Uses Gemini AI to generate tailored cold emails.\n- \ud83d\udcec **Automated Email Sending**: Sends emails via Gmail API with attachments.\n- \u2705 **Email Verification**: Uses SMTP and Maileroo API to validate emails before sending.\n- \ud83d\uddc4 **Database Management**: Stores recruiter data in PostgreSQL and tracks outreach progress.\n- \ud83d\udd04 **Batch Processing**: Sends emails in batches with randomized delays to prevent spam detection.",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "Features",
"symbol": "Features",
"chunk_idx": 1,
"size": 529,
"_id": "2b1ec077-3dbf-5a35-8275-b58b0b6597fd",
"_collection_name": "code_atlas"
}
},
{
"text": "1. **Resume Loading**: The script reads the resume and stores its details in AI memory.\n2. **Recruiter Selection**: Fetches recruiters from the database who haven't been contacted.\n3. **Email Verification**: Ensures the email is valid before sending.\n4. **AI-Generated Email**: Gemini AI crafts a custom email based on the recruiter's details.\n5. **Automated Sending**: Uses Gmail API to send the email with an attached resume.\n6. **Logging & Tracking**: Updates the database to mark recruiters as contacted.",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "How It Works",
"symbol": "How It Works",
"chunk_idx": 4,
"size": 508,
"_id": "6dcf5e32-a80e-5849-aa46-ad41296904c3",
"_collection_name": "code_atlas"
}
},
{
"text": "import os\nimport base64\nfrom google.oauth2.credentials import Credentials\nfrom google_auth_oauthlib.flow import InstalledAppFlow\nfrom google.auth.transport.requests import Request\nfrom googleapiclient.discovery import build\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\nfrom email.mime.base import MIMEBase\nfrom email import encoders\nimport time,random\nimport google.generativeai as genai\nimport pathlib\nimport os\nimport psycopg2\nimport pandas as pd\nimport smtplib\nAPI_KEY = \"YOUR_GEMINI_API_KEY\"\nSCOPES = [\"https://www.googleapis.com/auth/gmail.send\"]",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\hermesgpt.py",
"filename": "hermesgpt.py",
"repo": "HermesGPT",
"language": "python",
"type": "Module",
"start_line": 1,
"end_line": 22,
"symbol": "None",
"chunk_idx": 0,
"size": 590,
"_id": "c924aec1-3d7c-50ba-95a0-f9fc943c2685",
"_collection_name": "code_atlas"
}
},
{
"text": "async def api_name():\n return {\"api_name\": \"Intrusion Detection API\"}",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\router.py",
"filename": "router.py",
"repo": "IntrusionBackend",
"language": "python",
"type": "async_function",
"start_line": 40,
"end_line": 41,
"symbol": "api_name",
"chunk_idx": 5,
"size": 72,
"_id": "9bf1f6da-08a0-57e2-ad5a-6c00e473cfcc",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "### Public Endpoints \n#### Get API Information\n`GET /intrusiondetection/api_name`\n- **Response**: `{\"name\": \"Intrusion Detection API\", \"version\": \"1.0.0\"}` \n#### Health Check\n`GET /intrusiondetection/health`\n- **Response**: `{\"status\": \"healthy\"}` \n--- \n### Protected Endpoints (Requires Bearer Token) \n#### Hybrid Detection (Recommended)\n`POST /intrusiondetection/predict/hybrid`\nUses the hierarchical pipeline: **Anomaly detection (Unsupervised) -> Classification (Supervised)**.\n- **Logic**: If the Autoencoder or Isolation Forest flags the flow, the Supervised models (LightGBM, FFNN, etc.) are invoked. LightGBM provides the final \"Veto\" to determine if it is truly an attack. \n#### Prediction By Index\n`POST /intrusiondetection/predict/hybrid_by_index`\nUsed for testing existing samples from the `unscaled_test.parquet` dataset.\n- **Request Body**:\n```json\n{\n\"index\": 17502\n}\n``` \n#### Direct Model Endpoints\n- `POST /predict/logreg`\n- `POST /predict/lightgbm`\n- `POST /predict/ffnn`",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\documentation.md",
"filename": "documentation.md",
"repo": "IntrusionBackend",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "Intrusion Tracker Backend - Project Documentation",
"h2": "API Reference",
"symbol": "API Reference",
"chunk_idx": 4,
"size": 996,
"_id": "7d8dce36-12e3-5b9e-aebf-bacb964ca11b",
"_collection_name": "code_atlas"
}
},
{
"text": "def generate_stats():\n total_rows = len_df()\n print(f\"Starting evaluation on {total_rows} rows...\")\n \n y_true = []\n y_pred = []\n \n # Iterate through the dataset\n for idx in tqdm(range(total_rows)):\n try:\n result = predict.predict_attack_by_idx(idx)\n \n actual = result[\"target_class\"]\n # Logic: If status is Attack Detected, use the LightGBM prediction. \n # Otherwise, it's Benign (0).\n if result[\"status\"] == \"Attack Detected\":\n predicted = result.get(\"supervised\", {}).get(\"lightgbm\", 0)\n else:\n predicted = 0\n \n y_true.append(actual)\n y_pred.append(predicted)\n except Exception as e:\n print(f\"Error at index {idx}: {e}\")\n continue\n\n # 1. Generate Text Report\n report = classification_report(y_true, y_pred)\n cm = confusion_matrix(y_true, y_pred)\n \n output_text = \"=== CONFUSION MATRIX ===\\n\"\n output_text += str(cm) + \"\\n\\n\"\n output_text += \"=== CLASSIFICATION REPORT ===\\n\"\n output_text += report\n \n with open(\"confusion_matrix.txt\", \"w\") as f:\n f.write(output_text)\n \n print(\"\\nText report saved to confusion_matrix.txt\")\n\n # 2. Generate Heatmap Plot\n plt.figure(figsize=(12, 10))\n sns.heatmap(cm, annot=True, fmt='d', cmap='Blues', \n xticklabels=np.unique(y_true), \n yticklabels=np.unique(y_true))\n plt.title(\"Intrusion Detection Confusion Matrix\\n(Hierarchical Pipeline with LGBM Veto)\")\n plt.xlabel(\"Predicted Class\")\n plt.ylabel(\"Actual Class\")\n plt.savefig(\"confusion_matrix.png\", dpi=300)\n plt.close()\n \n print(\"Plot saved to confusion_matrix.png\")\n\n # 3. Generate Classification Report Heatmap\n report_dict = classification_report(y_true, y_pred, output_dict=True)\n # Convert to DataFrame and remove support/averages for plotting\n report_df = pd.DataFrame(report_dict).iloc[:-1, :].T\n report_df = report_df.drop(['accuracy', 'macro avg', 'weighted avg'], axis=0, errors='ignore')\n \n plt.figure(figsize=(10, 8))\n sns.heatmap(report_df, annot=True, cmap='Blues')\n plt.title(\"Classification Report Metrics per Class\")\n plt.savefig(\"classification_report.png\", dpi=300)\n plt.close()\n \n print(\"Plot saved to classification_report.png\")",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\stats.py",
"filename": "stats.py",
"repo": "IntrusionBackend",
"language": "python",
"type": "function",
"start_line": 14,
"end_line": 79,
"symbol": "generate_stats",
"chunk_idx": 1,
"size": 2387,
"_id": "efed5473-b5ea-53c4-bf8f-15863894d13a",
"_collection_name": "code_atlas"
}
},
{
"text": "async def api_name():\n return {\"api_name\": \"Intrusion Detection API\"}",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\router.py",
"filename": "router.py",
"repo": "IntrusionBackend",
"language": "python",
"type": "async_function",
"start_line": 40,
"end_line": 41,
"symbol": "api_name",
"chunk_idx": 5,
"size": 72,
"_id": "9bf1f6da-08a0-57e2-ad5a-6c00e473cfcc",
"_collection_name": "code_atlas"
}
},
{
"text": "Welcome to the **Intrusion Tracker Backend**, a high-performance network security monitoring system powered by FastAPI and a hierarchical machine learning pipeline. This system is designed to detect and classify network intrusions in real-time. \n---",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\documentation.md",
"filename": "documentation.md",
"repo": "IntrusionBackend",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "Intrusion Tracker Backend - Project Documentation",
"h2": "None",
"symbol": "Intrusion Tracker Backend - Project Documentation",
"chunk_idx": 0,
"size": 250,
"_id": "c66c7fb9-8127-51d3-80e8-e40321cbd828",
"_collection_name": "code_atlas"
}
},
{
"text": "- **LightGBM (Final Veto)**: A gradient boosting framework that provides the final classification.\n- **FFNN (Feed-Forward Neural Network)**: Deep learning model for multi-class classification.\n- **XGBoost & Logistic Regression**: Additional models used for ensemble verification and comparison. \n---",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\documentation.md",
"filename": "documentation.md",
"repo": "IntrusionBackend",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "Intrusion Tracker Backend - Project Documentation",
"h2": "System Architecture",
"symbol": "System Architecture",
"chunk_idx": 2,
"size": 300,
"_id": "175e6455-9b3c-5c8a-9eaa-f1b643ca0283",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "{\n \"repository_name\": \"IntrusionBackend\",\n \"owner\": \"mohakapoor\",\n \"tracked_branch\": \"dev\",\n \"current_commit_sha\": \"97eba2e1d8ec3a7da08c2e43a3f02d48b8b1f5a3\",\n \"indexed_commit_sha\": \"\",\n \"index_queue\": [\n \"*\"\n ],\n \"available_branches\": [\n \"dev\"\n ],\n \"topics\": [\n \"api\",\n \"backend\",\n \"fastapi\",\n \"inference\",\n \"knowledge-base\"\n ],\n \"languages\": [\n \"Python\"\n ],\n \"last_sync_timestamp\": \"2026-07-30T08:05:11.546021+00:00\"\n}",
"metadata": {
"repo": "IntrusionBackend",
"path": "knowledge_base/repos/IntrusionBackend/manifest.json",
"filename": "manifest.json",
"language": "text",
"type": "text",
"chunk_idx": 0,
"size": 458,
"_id": "af0fef8b-51eb-58d9-90d6-6887810d9835",
"_collection_name": "code_atlas"
}
},
{
"text": "Welcome to the **Intrusion Tracker Backend**, a high-performance network security monitoring system powered by FastAPI and a hierarchical machine learning pipeline. This system is designed to detect and classify network intrusions in real-time. \n---",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\documentation.md",
"filename": "documentation.md",
"repo": "IntrusionBackend",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "Intrusion Tracker Backend - Project Documentation",
"h2": "None",
"symbol": "Intrusion Tracker Backend - Project Documentation",
"chunk_idx": 0,
"size": 250,
"_id": "c66c7fb9-8127-51d3-80e8-e40321cbd828",
"_collection_name": "code_atlas"
}
},
{
"text": "You can explore the project and its capabilities live at:\n**[https://www.mohakapoor.in/projects/IntrusionDetection](https://www.mohakapoor.in/projects/IntrusionDetection)** \n---",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\README.md",
"filename": "README.md",
"repo": "IntrusionBackend",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "Intrusion Tracker Backend",
"h2": "Live Demo",
"symbol": "Live Demo",
"chunk_idx": 1,
"size": 178,
"_id": "2def1051-610d-504d-9077-7dbfd2fdb006",
"_collection_name": "code_atlas"
}
},
{
"text": "### Public Endpoints \n#### Get API Information\n`GET /intrusiondetection/api_name`\n- **Response**: `{\"name\": \"Intrusion Detection API\", \"version\": \"1.0.0\"}` \n#### Health Check\n`GET /intrusiondetection/health`\n- **Response**: `{\"status\": \"healthy\"}` \n--- \n### Protected Endpoints (Requires Bearer Token) \n#### Hybrid Detection (Recommended)\n`POST /intrusiondetection/predict/hybrid`\nUses the hierarchical pipeline: **Anomaly detection (Unsupervised) -> Classification (Supervised)**.\n- **Logic**: If the Autoencoder or Isolation Forest flags the flow, the Supervised models (LightGBM, FFNN, etc.) are invoked. LightGBM provides the final \"Veto\" to determine if it is truly an attack. \n#### Prediction By Index\n`POST /intrusiondetection/predict/hybrid_by_index`\nUsed for testing existing samples from the `unscaled_test.parquet` dataset.\n- **Request Body**:\n```json\n{\n\"index\": 17502\n}\n``` \n#### Direct Model Endpoints\n- `POST /predict/logreg`\n- `POST /predict/lightgbm`\n- `POST /predict/ffnn`",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\documentation.md",
"filename": "documentation.md",
"repo": "IntrusionBackend",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "Intrusion Tracker Backend - Project Documentation",
"h2": "API Reference",
"symbol": "API Reference",
"chunk_idx": 4,
"size": 996,
"_id": "7d8dce36-12e3-5b9e-aebf-bacb964ca11b",
"_collection_name": "code_atlas"
}
},
{
"text": "version: '3.8'\n\nservices:\n intrusion-tracker:\n build: .\n container_name: intrusion-api\n ports:\n - \"8000:8000\"\n restart: always\n env_file:\n - .env",
"metadata": {
"repo": "IntrusionBackend",
"path": "knowledge_base/repos/IntrusionBackend/docker-compose.yml",
"filename": "docker-compose.yml",
"language": "text",
"type": "text",
"chunk_idx": 0,
"size": 171,
"_id": "c720f8f0-b5a3-547f-87ba-2ae3bc79b573",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "def generate_captcha(text=None, width=IMG_WIDTH, height=IMG_HEIGHT, save_path=None):\n \"\"\"\n Generate a single enhanced CAPTCHA image.\n \n Args:\n text (str, optional): Text to render. If None, generates random text.\n width (int): Image width\n height (int): Image height\n save_path (str, optional): Path to save the image. If None, returns PIL Image.\n \n Returns:\n PIL Image if save_path is None, otherwise saves and returns the path\n \"\"\"\n # Generate random text if none provided\n if text is None:\n text = ''.join(random.choices(CHARS, k=random.randint(CAPTCHA_LEN_LOWER_LIMIT, CAPTCHA_LEN_UPPER_LIMIT)))\n \n # Randomize basic style\n bg_choice = random.choice([\"solid\", \"gradient\"])\n fg_color = rand_color(0, 80)\n \n if bg_choice == \"solid\":\n bg_color = rand_color(210, 255)\n bg = Image.new(\"RGB\", (width, height), color=bg_color)\n else:\n bg = gradient_bg(width, height)\n\n # Adjust font sizes for larger dimensions\n font_sizes = [int(height * 0.7), int(height * 0.75), int(height * 0.8), int(height * 0.85)]\n font_size = random.choice(font_sizes)\n \n # Use ImageCaptcha for base text rendering\n from captcha.image import ImageCaptcha\n image = ImageCaptcha(width=width, height=height, fonts=None, font_sizes=[font_size])\n \n # Draw base image\n base = Image.frombytes('RGB', (width, height), image.generate_image(text).tobytes())\n\n # Apply enhancements\n angle = random.uniform(-6, 6)\n base = base.rotate(angle, resample=Image.BILINEAR, expand=False, fillcolor=bg.getpixel((0,0)))\n\n # Perspective warp (very light)\n if random.random() < 0.6:\n base = perspective_warp(base, max_ratio=0.025)\n\n # Add interference\n base = add_interference(base, line_range=(0, 3), dot_range=(10, 60))\n\n # Noise + blur + JPEG recompression\n base = add_noise_and_blur(base, noise_sigma=(0.0, 5.0), blur_sigma=(0.0, 0.7), motion_prob=0.12)\n base = jpeg_recompress(base, qmin=72, qmax=92)\n\n # Optional low contrast\n if random.random() < 0.2:\n base = base.point(lambda p: int(p*0.95 + 6))\n\n # Convert to grayscale if specified\n if GRAYSCALE:\n base = base.convert('L')\n \n # Save or return\n if save_path:\n base.save(save_path)\n return save_path\n else:\n return base",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\src\\generateCaptcha.py",
"filename": "generateCaptcha.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "function",
"start_line": 104,
"end_line": 170,
"symbol": "generate_captcha",
"chunk_idx": 7,
"size": 2362,
"_id": "5961a050-0f46-5993-aadb-d341153dadc1",
"_collection_name": "code_atlas"
}
},
{
"text": "def main():\n device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n in_ch = 1 if cfg.grayscale else 3\n\n print(\"Creating datasets...\")\n train_ds = CaptchaDataset(\"train\")\n val_ds = CaptchaDataset(\"val\")\n \n # Debug: Check vocabulary\n print(f\"Vocabulary size: {vocab_size()}\")\n print(f\"First 10 characters: {list(cfg.chars)[:10]}\")\n print(f\"First 10 itos: {itos[:10]}\")\n \n print(f\"Training dataset size: {len(train_ds)}\")\n print(f\"Validation dataset size: {len(val_ds)}\")\n\n train_dl = DataLoader(train_ds, batch_size=cfg.batch_size, shuffle=True, \n num_workers=cfg.num_workers, pin_memory=True, \n drop_last=True, collate_fn=ctc_collate)\n val_dl = DataLoader(val_ds, batch_size=cfg.batch_size, shuffle=False, \n num_workers=cfg.num_workers, pin_memory=True, \n drop_last=True, collate_fn=ctc_collate)\n\n model = CRNN(vocab_size=vocab_size()).to(device)\n \n # Initialize final layer with small weights for stability\n with torch.no_grad():\n torch.nn.init.uniform_(model.fc.weight, -1e-3, 1e-3)\n torch.nn.init.zeros_(model.fc.bias)\n \n criterion = nn.CTCLoss(blank=0, zero_infinity=True)\n optimizer = torch.optim.AdamW(model.parameters(), lr=3e-4, weight_decay=1e-4)\n scaler = torch.amp.GradScaler('cuda', enabled=False) # Disable AMP for stability\n\n # Epoch-based training with scheduler\n epochs = 40 # Increased for OneCycleLR\n scheduler = torch.optim.lr_scheduler.OneCycleLR(\n optimizer, max_lr=3e-4, steps_per_epoch=len(train_dl), epochs=epochs\n )\n print(f\"\\nStarting training for {epochs} epochs...\")\n \n metrics = TrainingMetrics()\n \n # Early stopping setup\n best_val_loss = float('inf')\n patience = 5 # Stop if no improvement for 5 epochs\n patience_counter = 0\n early_stop = False\n\n for epoch in range(epochs):\n # Training phase\n model.train()\n total_train_loss = 0\n num_batches = 0\n \n print(f\"\\nEpoch {epoch+1}/{epochs}\")\n print(\"Training...\")\n \n for batch_idx, batch in enumerate(train_dl):\n images, targets_flat, target_lengths, input_lengths, paths = batch\n \n # CTC sanity checks (first batch of each epoch)\n if batch_idx == 0:\n assert targets_flat.numel() == target_lengths.sum().item(), \"Target lengths mismatch\"\n assert torch.all(target_lengths <= input_lengths), \"Target longer than input\"\n print(f\" Batch 0 sanity: input_lens={input_lengths[:5].tolist()}, target_lens={target_lengths[:5].tolist()}\")\n print(f\" Image stats: min={images.min():.3f}, max={images.max():.3f}, mean={images.mean():.3f}\")\n \n \n images = images.to(device)\n targets_flat = targets_flat.to(device)\n target_lengths = target_lengths.to(device)\n input_lengths = input_lengths.to(device)\n\n optimizer.zero_grad(set_to_none=True)\n\n with torch.amp.autocast('cuda', enabled=False):\n logits = model(images)\n log_probs = logits.log_softmax(dim=-1)\n loss = criterion(log_probs, targets_flat, input_lengths, target_lengths)\n \n loss.backward()\n \n # Gradient clipping to prevent exploding gradients\n torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)\n \n optimizer.step()\n scheduler.step() # OneCycleLR step per batch\n\n total_train_loss += loss.item()\n num_batches += 1\n \n # Progress update every 50 batches\n if batch_idx % 50 == 0:\n print(f\" Batch {batch_idx}/{len(train_dl)} - Loss: {loss.item():.4f}\")\n \n avg_train_loss = total_train_loss / num_batches\n \n # Validation phase\n model.eval()\n total_val_loss = 0\n num_val_batches = 0\n \n print(\"Validating...\")\n with torch.no_grad():\n for batch in val_dl:\n images, targets_flat, target_lengths, input_lengths, paths = batch\n images = images.to(device)\n targets_flat = targets_flat.to(device)\n target_lengths = target_lengths.to(device)\n input_lengths = input_lengths.to(device)\n \n logits = model(images)\n log_probs = logits.log_softmax(dim=-1)\n loss = criterion(log_probs, targets_flat, input_lengths, target_lengths)\n \n total_val_loss += loss.item()\n num_val_batches += 1\n \n avg_val_loss = total_val_loss / num_val_batches\n \n print(f\"Epoch {epoch+1}/{epochs} Summary:\")\n print(f\" Train Loss: {avg_train_loss:.4f}\")\n print(f\" Val Loss: {avg_val_loss:.4f}\")\n metrics.add_epoch(epoch+1, avg_train_loss, avg_val_loss)\n \n # Enhanced early stopping check\n val_train_ratio = avg_val_loss / (avg_train_loss + 1e-8) # Avoid division by zero\n \n if avg_val_loss < best_val_loss:\n best_val_loss = avg_val_loss\n patience_counter = 0\n print(f\" New best validation loss: {best_val_loss:.4f}\")\n print(f\" Val/Train ratio: {val_train_ratio:.3f}\")\n \n # Save best model checkpoint with metadata\n checkpoint = {\n 'epoch': epoch + 1,\n 'model_state_dict': model.state_dict(),\n 'optimizer_state_dict': optimizer.state_dict(),\n 'scheduler_state_dict': scheduler.state_dict(),\n 'best_val_loss': best_val_loss,\n 'train_loss': avg_train_loss,\n 'val_loss': avg_val_loss,\n 'val_train_ratio': val_train_ratio,\n 'config': {\n 'vocab_size': vocab_size(),\n 'hidden_size': 320,\n 'total_stride': cfg.total_stride,\n 'H': cfg.H,\n 'W_max': cfg.W_max\n }\n }\n torch.save(checkpoint, \"checkpoints/best_model.pth\")\n print(f\" Best model saved to checkpoints/best_model.pth\")\n \n else:\n patience_counter += 1\n print(f\" No improvement for {patience_counter} epochs\")\n print(f\" Val/Train ratio: {val_train_ratio:.3f}\")\n \n # Enhanced early stopping: Check both absolute loss and ratio\n if patience_counter >= patience or val_train_ratio > 3.0: # Stop if ratio > 3x\n if val_train_ratio > 3.0:\n print(f\" Early stopping triggered! Val/Train ratio too high: {val_train_ratio:.3f}\")\n else:\n print(f\" Early stopping triggered! No improvement for {patience} epochs\")\n early_stop = True\n break\n\n # Test some predictions\n if epoch % 2 == 0: # Every 2 epochs\n print(\"Sample predictions:\")\n with torch.no_grad():\n test_batch = next(iter(val_dl))\n test_images = test_batch[0][:5].to(device) # First 5 images\n print(f\" Input image shape: {test_images.shape}\")\n print(f\" Input image min/max: {test_images.min():.4f}/{test_images.max():.4f}\")\n test_logits = model(test_images)\n \n # Debug: Check logits shape and values\n print(f\" Logits shape: {test_logits.shape}\")\n print(f\" Expected logits shape: [W//stride, B, V] = [{cfg.W_max}//{cfg.total_stride}, 5, 63] = [{cfg.W_max//cfg.total_stride}, 5, 63]\")\n print(f\" Logits min/max: {test_logits.min():.4f}/{test_logits.max():.4f}\")\n \n # Check raw predictions and blank probability (from softmax)\n raw_preds = test_logits.argmax(dim=-1)\n probs = test_logits.log_softmax(-1).exp()\n avg_blank_prob = probs[..., 0].mean().item()\n print(f\" Raw predictions shape: {raw_preds.shape}\")\n print(f\" Raw predictions sample: {raw_preds[:10, 0].tolist()}\")\n print(f\" Avg blank prob (softmax): {avg_blank_prob:.4f}\")\n print(f\" Blank probability (argmax): {(raw_preds == 0).float().mean():.4f}\")\n \n test_preds = ctc_greedy_decode(test_logits)\n \n # Decode the target integers back to text strings with proper offsets\n targets_flat, target_lengths = test_batch[1], test_batch[2]\n offsets = torch.zeros(len(target_lengths), dtype=torch.long)\n offsets[1:] = torch.cumsum(target_lengths[:-1], dim=0)\n test_targets = []\n for i in range(min(5, len(target_lengths))):\n s = offsets[i].item()\n e = s + target_lengths[i].item()\n indices = targets_flat[s:e].tolist()\n test_targets.append(decode_indices(indices))\n \n # Calculate CER for this batch\n batch_cer = sum(cer(p, t) for p, t in zip(test_preds, test_targets)) / len(test_targets)\n print(f\" Val CER (approx): {batch_cer:.3f}\")\n \n for i, (pred, target) in enumerate(zip(test_preds, test_targets)):\n print(f\" {i}: Predicted='{pred}', Target='{target}'\")\n \n metrics.add_predictions(test_preds, test_targets)\n\n if early_stop:\n print(f\"\\nTraining stopped early at epoch {epoch+1} due to no improvement!\")\n else:\n print(f\"\\nTraining completed for all {epochs} epochs!\")\n \n # Save final model\n final_checkpoint = {\n 'epoch': epoch + 1,\n 'model_state_dict': model.state_dict(),\n 'optimizer_state_dict': optimizer.state_dict(),\n 'scheduler_state_dict': scheduler.state_dict(),\n 'final_val_loss': avg_val_loss,\n 'final_train_loss': avg_train_loss,\n 'config': {\n 'vocab_size': vocab_size(),\n 'hidden_size': 320,\n 'total_stride': cfg.total_stride,\n 'H': cfg.H,\n 'W_max': cfg.W_max\n }\n }\n torch.save(final_checkpoint, \"checkpoints/final_model.pth\")\n print(f\"Final model saved to checkpoints/final_model.pth\")\n \n print(\"\\nGenerating training metrics and plots...\")\n os.makedirs(\"Metrics\", exist_ok=True)\n metrics.plot_losses()\n metrics.plot_loss_comparison()\n metrics.save_metrics()\n \n # Final validation test\n model.eval()\n with torch.no_grad():\n images, targets_flat, target_lengths, input_lengths, paths = next(iter(val_dl))\n images = images.to(device)\n logits = model(images)\n preds = ctc_greedy_decode(logits)\n \n print(\"\\nFinal validation predictions:\")\n for i, pred in enumerate(preds[:10]):\n print(f\" {i}: {pred}\")",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\train.py",
"filename": "train.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "function",
"start_line": 18,
"end_line": 274,
"symbol": "main",
"chunk_idx": 2,
"size": 11157,
"_id": "dbf40dd7-cc46-5fee-98fa-69ef45e69d5d",
"_collection_name": "code_atlas"
}
},
{
"text": "### \u2705 Completed Components\n- **Dataset Generation**: Synthetic CAPTCHA creation with train/val/test splits (8k train, 1k val)\n- **Configuration**: Centralized config with image dimensions and training parameters\n- **Vocabulary System**: Character encoding/decoding with CTC blank token support (63 classes)\n- **CTC Collate Function**: Proper batching for variable-length sequences\n- **CTC Decoding**: Greedy decode for inference\n- **PyTorch Dataset Class**: Image loading and preprocessing with proper cv2 resizing\n- **CRNN Model**: CNN encoder + BiLSTM + LayerNorm + linear output (working!)\n- **Training Loop**: Complete epoch-based training pipeline with validation\n- **Metrics & Plotting**: Training/validation loss tracking with beautiful visualizations\n- **Debugging Tools**: Comprehensive logging of logits, predictions, and model health \n### \u2705 What's Working\n- **Training Pipeline**: Stable training loop with excellent loss convergence",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\README.md",
"filename": "README.md",
"repo": "CaptchaOCR",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "CAPTCHA OCR Project",
"h2": "\ud83c\udfd7\ufe0f Current Status",
"symbol": "\ud83c\udfd7\ufe0f Current Status",
"chunk_idx": 3,
"size": 945,
"_id": "cc52b2b4-6738-5973-9c50-29fc8882ca66",
"_collection_name": "code_atlas"
}
},
{
"text": "def initial_outreach(user,company,recruiter_name,title=\"HR Manager\"):\n response = chat.send_message(\n content=[\n f\"\"\"\n Generate a professional cold email to {recruiter_name}, with the title {title} at {company}, inquiring about internship opportunities for the (fill this according to my resume and company) position based on the resume details provided to you earlier.\n Make sure it is custom tailored to me.\n\n 1.Start with a concise introduction about myself, including key skills and relevant experience.\n 2.Express genuine interest in the company and why I want to intern there.\n 3.Briefly mention a key project or achievement that aligns with the role.\n 4.End with a polite call to action, asking about internship openings or guidance on applying.\n 5.Keep the email professional, friendly, and under 200 words.\n 6.Make sure there are no placeholders in the text\n You could include a small text in the end like : \"P.S Im mailing this through a automated internship applying bot made by me\" do it a bit creatively\n Make sure you only return the mail body & subject nothing else.\n \"\"\"\n ]\n )\n \n \n str = response.text\n str = str.split('\\n',1)\n subject,body = str[0],str[1]\n print(subject)\n print(body)\n\n return subject,body",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\hermesgpt.py",
"filename": "hermesgpt.py",
"repo": "HermesGPT",
"language": "python",
"type": "function",
"start_line": 126,
"end_line": 152,
"symbol": "initial_outreach",
"chunk_idx": 8,
"size": 1399,
"_id": "d86b54a9-1a4d-5066-9a7d-d30e8d47bae3",
"_collection_name": "code_atlas"
}
},
{
"text": "with gr.Blocks(title=\"CAPTCHA OCR (checkpoint)\") as demo:\n gr.Markdown(\"## CAPTCHA OCR \")\n\n with gr.Row():\n # Left column: Generate button + Solve button stacked vertically\n with gr.Column(scale=1):\n gen_btn = gr.Button(\"Generate CAPTCHA\", variant=\"primary\")\n solve_btn = gr.Button(\"Solve\", interactive=False, variant=\"secondary\")\n \n # Right column: Ground Truth\n gt_out = gr.Textbox(label=\"Ground Truth\", interactive=False, text_align=\"center\")\n\n with gr.Row():\n img_out = gr.Image(label=\"Generated CAPTCHA\", type=\"pil\")\n path_box = gr.Textbox(label=\"Internal Path\", interactive=False, visible=False)\n\n # Prediction row split into two columns\n with gr.Row():\n accuracy_out = gr.Textbox(label=\"Character Accuracy\", interactive=False, text_align=\"center\")\n pred_out = gr.Textbox(label=\"Prediction\", interactive=False, text_align=\"center\")\n\n # Generate: outputs image, ground truth, path, and enables Solve (green)\n gen_btn.click(\n fn=ui_generate,\n outputs=[img_out, gt_out, path_box, solve_btn],\n )\n\n # Solve: only uses the internal path (no upload option anymore)\n solve_btn.click(\n fn=ui_solve,\n inputs=[path_box, gt_out],\n outputs=[accuracy_out, pred_out],\n )\nif __name__ == \"__main__\":\n demo.launch()",
"metadata": {
"path": "knowledge_base\\repos\\CaptchaOCR\\app.py",
"filename": "app.py",
"repo": "CaptchaOCR",
"language": "python",
"type": "Module",
"start_line": 66,
"end_line": 101,
"symbol": "None",
"chunk_idx": 5,
"size": 1359,
"_id": "d33e2103-8a96-5c78-a5ce-4f9aff805aa9",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "def sampler(target_class):\n\n sample_df = df.filter(pl.col(\"Attack\") == target_class).sample(1)\n \n if sample_df.height == 0:\n raise ValueError(f\"No data found for class {target_class}\")\n \n idx = sample_df[\"original_index\"][0]\n features = sample_df.drop([\"Attack\", \"original_index\"]).to_numpy()\n \n return features, idx",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\utils.py",
"filename": "utils.py",
"repo": "IntrusionBackend",
"language": "python",
"type": "function",
"start_line": 27,
"end_line": 37,
"symbol": "sampler",
"chunk_idx": 2,
"size": 347,
"_id": "54f49c6b-aa1a-56a9-aa35-f58729154a55",
"_collection_name": "code_atlas"
}
},
{
"text": "This project is open-source under the [MIT License](LICENSE).",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "License",
"symbol": "License",
"chunk_idx": 7,
"size": 61,
"_id": "78185ef9-2fd2-5572-ab65-88d727f873b2",
"_collection_name": "code_atlas"
}
},
{
"text": "1. **Resume Loading**: The script reads the resume and stores its details in AI memory.\n2. **Recruiter Selection**: Fetches recruiters from the database who haven't been contacted.\n3. **Email Verification**: Ensures the email is valid before sending.\n4. **AI-Generated Email**: Gemini AI crafts a custom email based on the recruiter's details.\n5. **Automated Sending**: Uses Gmail API to send the email with an attached resume.\n6. **Logging & Tracking**: Updates the database to mark recruiters as contacted.",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "How It Works",
"symbol": "How It Works",
"chunk_idx": 4,
"size": 508,
"_id": "6dcf5e32-a80e-5849-aa46-ad41296904c3",
"_collection_name": "code_atlas"
}
},
{
"text": "Feel free to fork this project and submit pull requests! \ud83d\ude80",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "Contributing",
"symbol": "Contributing",
"chunk_idx": 6,
"size": 58,
"_id": "4dcbff5d-f7d7-5fb5-aa1c-b81dd0b70acd",
"_collection_name": "code_atlas"
}
},
{
"text": "### 1. Clone the Repository \n```sh\ngit clone https://github.com/your-username/HermesGPT.git\ncd HermesGPT\n``` \n### 2. Install Dependencies \nMake sure you have Python installed, then install the required packages: \n```sh\npip install -r requirements.txt\n``` \n### 3. Configure Database \nSet up a PostgreSQL database with the following schema: \n```sql\nCREATE TABLE recruiters (\nemail TEXT PRIMARY KEY,\nrecruiter_name TEXT,\ncompany_name TEXT,\nrole TEXT,\ncontacted BOOLEAN DEFAULT FALSE\n);\n``` \n### 4. Set Up Gmail API \n1. Enable the Gmail API from Google Cloud Console.\n2. Download `credentials.json` and place it in the project directory.\n3. Run authentication: \n```sh\npython main.py\n``` \n### 5. API Keys \n- **Gemini AI API**: Add your Gemini API key to the `API_KEY` variable. \n### 6. Load Recruiter Data \nPrepare a CSV file (`recruiters.csv`) with the following columns: \n| Email | Name | Company | Title |\n|-------|------|---------|-------|",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "Setup Instructions",
"symbol": "Setup Instructions",
"chunk_idx": 2,
"size": 953,
"_id": "c1147930-c01b-59e0-a7d4-b6330fbf4ec4",
"_collection_name": "code_atlas"
}
}
],
[
{
"text": "import os\nimport base64\nfrom google.oauth2.credentials import Credentials\nfrom google_auth_oauthlib.flow import InstalledAppFlow\nfrom google.auth.transport.requests import Request\nfrom googleapiclient.discovery import build\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\nfrom email.mime.base import MIMEBase\nfrom email import encoders\nimport time,random\nimport google.generativeai as genai\nimport pathlib\nimport os\nimport psycopg2\nimport pandas as pd\nimport smtplib\nAPI_KEY = \"YOUR_GEMINI_API_KEY\"\nSCOPES = [\"https://www.googleapis.com/auth/gmail.send\"]",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\hermesgpt.py",
"filename": "hermesgpt.py",
"repo": "HermesGPT",
"language": "python",
"type": "Module",
"start_line": 1,
"end_line": 22,
"symbol": "None",
"chunk_idx": 0,
"size": 590,
"_id": "c924aec1-3d7c-50ba-95a0-f9fc943c2685",
"_collection_name": "code_atlas"
}
},
{
"text": "google-auth-oauthlib\ngoogle-auth\ngoogle-auth-httplib2\ngoogle-api-python-client\npsycopg2\npandas\nsmtplib\nemail\nbase64\nrequests\ngoogle-generativeai\n",
"metadata": {
"repo": "HermesGPT",
"path": "knowledge_base/repos/HermesGPT/requirements.txt",
"filename": "requirements.txt",
"language": "text",
"type": "text",
"chunk_idx": 0,
"size": 145,
"_id": "e7295db8-34c6-55bf-a814-702ef9f1cf9a",
"_collection_name": "code_atlas"
}
},
{
"text": "def _predict_lightgbm(raw_sample, scaled_data=None):\n start_time = time.perf_counter()\n if scaled_data is None:\n scaled_data = scale_supervised(raw_sample)\n y_pred = LIGHTGBM_MODEL.predict(scaled_data)\n latency = time.perf_counter() - start_time\n # Use .ravel()[0] to handle both scalars and arrays\n return int(np.atleast_1d(y_pred).ravel()[0]), latency",
"metadata": {
"path": "knowledge_base\\repos\\IntrusionBackend\\predict.py",
"filename": "predict.py",
"repo": "IntrusionBackend",
"language": "python",
"type": "function",
"start_line": 109,
"end_line": 116,
"symbol": "_predict_lightgbm",
"chunk_idx": 7,
"size": 378,
"_id": "4ae4ce30-8954-5629-a809-32a326f77136",
"_collection_name": "code_atlas"
}
},
{
"text": "- \ud83d\udcc4 **Resume Parsing**: Loads and processes resume data for personalized email generation.\n- \ud83e\udd16 **AI-Powered Emails**: Uses Gemini AI to generate tailored cold emails.\n- \ud83d\udcec **Automated Email Sending**: Sends emails via Gmail API with attachments.\n- \u2705 **Email Verification**: Uses SMTP and Maileroo API to validate emails before sending.\n- \ud83d\uddc4 **Database Management**: Stores recruiter data in PostgreSQL and tracks outreach progress.\n- \ud83d\udd04 **Batch Processing**: Sends emails in batches with randomized delays to prevent spam detection.",
"metadata": {
"path": "knowledge_base\\repos\\HermesGPT\\README.md",
"filename": "README.md",
"repo": "HermesGPT",
"language": "markdown",
"type": "section",
"start_line": "None",
"end_line": "None",
"h1": "HermesGPT - Automated Internship Outreach Bot \ud83d\ude80",
"h2": "Features",
"symbol": "Features",
"chunk_idx": 1,
"size": 529,
"_id": "2b1ec077-3dbf-5a35-8275-b58b0b6597fd",
"_collection_name": "code_atlas"
}
},