Skip to content

Instantly share code, notes, and snippets.

@salmanmaq
salmanmaq / export_onnx_with_nms.py
Last active December 10, 2024 16:38
Export YOLO11 to ONNX with NMS
import os
from typing import Literal, Optional
import cv2
import numpy as np
import onnx
import onnxruntime as ort
import onnxslim
import torch
import torchvision
@salmanmaq
salmanmaq / combine_core_noncore_rejected_date.py
Last active November 20, 2018 19:34
Combine Core, Non-Core, and Rejected Data
import json
import numpy as np
import pandas as pd
inspire_core_list_path = 'inspire_core_list.txt'
inspire_noncore_list_path = 'inspire_noncore_list.txt'
inspire_harvested_data_path = 'inspire_harvested_data.json'
inspire_core_data_path = 'inspire_core_records.json'
inspire_noncore_data_path = 'inspire_noncore_records.json'
save_path = 'inspire_data.df'
@salmanmaq
salmanmaq / get_core_and_non_core_list.py
Last active November 16, 2018 17:23
Get a list of arXiv identifiers of Core and Non-Core records in INSPIRE
"""
Get the arxiv ids of all the Core and Non-Core records in INSPIRE.
"""
from invenio_search import current_search_client as es
from elasticsearch.helpers import scan
import numpy as np
core = []
non_core = []
@salmanmaq
salmanmaq / makejson.py
Last active November 20, 2018 17:31
makejson.py
from __future__ import absolute_import, division, print_function
import json
def makejson(obj, eng):
'''
title = obj.extra_data['source_data']['data']['titles'][0]['title']
abstracts = obj.extra_data['source_data']['data']['abstracts'][0]['value']
authors_dict = obj.extra_data['source_data']['data']['authors']
arxiv_eprints = obj.extra_data['source_data']['data']['arxiv_eprints']
@salmanmaq
salmanmaq / article.py
Created November 16, 2018 13:47
Modified article.py
# -*- coding: utf-8 -*-
#
# This file is part of INSPIRE.
# Copyright (C) 2014-2017 CERN.
#
# INSPIRE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@salmanmaq
salmanmaq / generate_core_and_noncore_data.py
Last active November 20, 2018 16:17
Generate Core and non-Core data for INSPIRE classifier
'''
This snippet is supposed to be run from within the inspirehep shell.
'''
from elasticsearch.helpers import scan
from inspire_utils.record import get_value
from invenio_search import current_search_client as es
import json
core_records = []