|
import gradio as gr |
|
from transformers import pipeline, AutoTokenizer |
|
|
|
scibert_tokenizer = AutoTokenizer.from_pretrained('allenai/scibert_scivocab_uncased') |
|
|
|
classifier = pipeline("text-classification", |
|
model="tugot17/S2ORC-topic-classificaton", |
|
max_length=512, |
|
tokenizer=scibert_tokenizer) |
|
|
|
|
|
title_1 = "Depth Control Method of Profiling Float Based on an Improved Double PD Controller" |
|
abstract_1 = "A kinematic equation of profiling float is nonlinear and has time-varying parameters. Traditional PD controllers not only demonstrate an inconsistent response to different depth controls but also face problems of overshooting and high power consumption. To realize the goal of depth control of profiling buoy under low power consumption, an improved double PD control method was proposed in this paper. The real-time prediction of position and low-power running of the sensor were realized through sparse sampling and depth prediction. The combination control over position, speed, and flow was realized by introducing the speed and flow expectation function. Then, a MATLAB/Simulink simulation model was constructed, and the proposed controller was compared with a single PD controller and an improved single PD controller. Among ten depth control tests, the proposed method was superior given its short response time, small overshooting, small steady-state error, and low power consumption. Moreover, it achieved a consistent control effect on different target depths. The simulation results demonstrated that a nonlinear and time-varying floating system controlled by the proposed method has favorable robustness and stability. This system will consume minimal power simultaneously." |
|
text_1 = """ With the increase in the cognition of marine and accelerating ocean exploitation, research and development of submersible vehicles with large diving depth and long voyage has become a research hotspot [1] . Autonomous underwater vehicle (AUV) [2] , autonomous profile observation float (hereinafter referred to as ''float'') [3] , manned deep submersible vehicle, and underwater gliders have attracted considerable attention and have been studied extensively.""" |
|
|
|
title_2 = "Cosmography and Data Visualization" |
|
abstract_2 = " Cosmography, the study and making of maps of the universe or cosmos, is a field where visual representation benefits from modern three-dimensional visualization techniques and media. At the extragalactic distance scales, visualization is contributing in understanding the complex structure of the local universe, in terms of spatial distribution and flows of galaxies and dark matter. In this paper, we report advances in the field of extragalactic cosmography obtained using the SDvision visualization software in the context of the Cosmicflows Project. Here, multiple visualization techniques are applied to a variety of data products: catalogs of galaxy positions and galaxy peculiar velocities, reconstructed velocity field, density field, gravitational potential field, velocity shear tensor viewed in terms of its eigenvalues and eigenvectors, envelope surfaces enclosing basins of attraction. These visualizations, implemented as high-resolution images, videos, and interactive viewers, have contributed to a number of studies: the cosmography of the local part of the universe, the nature of the Great Attractor, the discovery of the boundaries of our home supercluster of galaxies Laniakea, the mapping of the cosmic web, the study of attractors and repellers." |
|
text_2 = """Throughout the ages, astronomers have strived to materialize their discoveries and understanding of the cosmos by the means of visualizations. The oldest known depiction of celestial objects, the Nebra sky disc, dates back from the Bronze age, 3600 years ago (Benson 2014) . While most of the astronomical representations are projections to two dimensional sketches and images, the introduction of the third dimension in depictive apparatuses has been sought by astronomers as an essential mean to promote understanding. Such objects as the armillary spheres, dating back from the Hellenistic world, or the modern era orreries used to mechanically model the solar system, played an important role in the history of astronomy. Today, computer-based interactive three-dimensional visualization techniques have become a fruitful research tool. Here, we present the impact of visualization on cosmography in the context of the Cosmicflows Project.""" |
|
|
|
class_map = {"LABEL_0": 'Biology π¦ π§¬π¦', |
|
"LABEL_1": 'Chemistry π¨βπ¬βοΈπ¬', |
|
"LABEL_2": 'Computer Science π€π»π', |
|
"LABEL_3": 'Medicine ππ¨ββοΈπ©ββοΈ', |
|
"LABEL_4": 'Physics ππ π', |
|
} |
|
|
|
['Biology', 'Chemistry', 'Computer Science', 'Medicine', 'Physics'] |
|
|
|
def predict(title:str, abstract: str, aricle_text): |
|
output = {} |
|
|
|
input_text = f"{title}\n {abstract}\n {aricle_text}" |
|
|
|
results = classifier(input_text, top_k=None) |
|
print(results) |
|
|
|
for result in results: |
|
label = class_map[result["label"]] |
|
output[label] = result["score"] |
|
|
|
return output |
|
|
|
iface = gr.Interface( |
|
fn=predict, |
|
inputs=[gr.Textbox(lines=1, label="Title"), |
|
gr.Textbox(lines=5, label="Absract"), |
|
gr.Textbox(lines=5, label="Article Text")], |
|
outputs=gr.Label(num_top_classes=5), |
|
examples=[[title_1, abstract_1, text_1], [title_2, abstract_2, text_2]], |
|
title="Article topic classifier", |
|
description= "Upload the paper title, its abstract, and the beginning of the text. Our model will figure out whether this is a Biology, Chemistry, Computer Science, Medicine or Physics related article." |
|
) |
|
|
|
iface.launch(debug=True) |
|
|
|
|
|
|